Jump to content
Sign in to follow this  
davej

Style options with Javascript?

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.

Share this post


Link to post
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.

Share this post


Link to post
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. :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...