Results 1 to 6 of 6

Thread: resetStyles(element) anything like that?

  1. #1
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default resetStyles(element) anything like that?

    Hello everybody,
    Can anyone tell me if there is any function like resetStyles in javascript that zaps all javascript made style changes? For e.g if there is a division with a border of 1px dotted and when certain conditions are met javascript changes the border to 1px solid red. Now how do I change the style back to 1px solid(it's not just the case with divs and the default styles can be variable)?

    Thanks for your time and interest in my post.

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by shachi View Post
    Can anyone tell me if there is any function like resetStyles in javascript that zaps all javascript made style changes?
    Not automatically, no. You would have to track the changes that you make, yourself.

    Assigning an empty string to a property of an in-line style object will remove that declaration:

    Code:
    element.style.color = 'red'; /* #ff0000 */
    element.style.color = ''; /* Colour now taken from cascade. */
    That would also remove any such declarations applied by the style attribute in markup as they are equivalent.

    HTML Code:
    <span style="color: red;">...</span>
    You're probably aware of this, but just in case you weren't...

    Mike

  3. #3
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So, there is not any *safe* way to do it?

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by shachi
    So, there is not any *safe* way to do it?
    Nothing comes to mind, no.

    Mike

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    refresh


    Is there any way to reset the page without loading, overall? Not just styles, but perhaps everything?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    drj33: that would be really annoying ;p

    mwinter: Thanks for your reply. I guess I will have to try something new. Thanks again for your time.


    drj33: there probably isn't one right now but I guess there will soon be.

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
  •