PDA

View Full Version : Select tag style using Javascript


pradeepg459
04-14-2010, 02:15 PM
Hi everyone

I need to apply styles for select tag when it is in disabled mode using JavaScript ...

Need suggestions....

Thanks in ADV..
Pradeep.

Dormilich
04-14-2010, 02:23 PM
use JS to style the select, if JS is disabled, the default style (you defined) will show.

VIPStephan
04-14-2010, 02:33 PM
It’s not entirely clear to me what you are trying to achieve, pradeep459, but JavaScript isn’t (primarily) made to style HTML but to add functionality. So, if you need to apply styles based on a certain condition with JavaScript then add a CSS hook (e. g. a class) to the element with JS and style it with CSS.


HTML is there as it is (and works without relying on JS functionality)
JS adds a class to HTML
CSS styles HTML using that class selector


This is separation of content, style, and behavior, a. k. a. behavioral separation (http://www.alistapart.com/articles/behavioralseparation).

Alex Vincent
04-15-2010, 12:25 AM
This thread is in the wrong forum. http://codingforums.com/showthread.php?t=17515