Jump to content

Style options with Javascript?


davej
 Share

Recommended Posts

I've changed styles using document.getElementById("id").style.xxx But... Can you apply a different _named_ style to an element?Can you apply a different external stylesheet to a page? Thanks.

Link to comment
Share on other sites

Libraries like jQuery have shortcuts to do that, but each element has a property called either class or className depending on a browser, which contains the contents of the class attribute. You can add and remove classes from that like you would directly on an element tag. To add a new stylesheet you would create a new link element, set the appropriate attributes to have it refer to a stylesheet, and append the link element to the head element.

Link to comment
Share on other sites

You can't apply css to select option, but thanks to jQuery, try to search "jquery selectbox", you'll found what you need. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...