SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru toasti's Avatar
    Join Date
    Feb 2004
    Location
    Grahamstown
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Removing all the styles from an element

    Hi

    How does one remove all the styles associated with an emement.

    eg: if you have
    <div style="margin:solid 1px; color:white;background-color:black" ></div>

    how would you clear this with javascript so that you have the equivalent of:
    <div style=""></div>

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Use removeAttribute to remove the style attribute:
    Code:
    thediv.removeAttribute('style');


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
  •