SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2004
    Location
    UK
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Restoring CSS Properties

    Hi,

    how do I restore CSS properties for a selected element? I want to change the background-color of a particular item on click, then restore the original CSS bgcolor from the stylesheet when it's clicked a 2nd time.

    The item in question has a CSS class applied to it from the stylesheet.


    Cheers,

    a|x

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can remove all of an element's inline styles by setting element.style.cssText='';

    If you only want to remove the background-color use element.style.backgroundColor=''.

    The stylesheet properties will then apply to the element again.

  3. #3
    SitePoint Member
    Join Date
    May 2004
    Location
    UK
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks mrhoo, I will try that.

    a|x


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •