Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Remove inline CSS generated from JS animation?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #148395
    Rugg
    Participant

    Hi,

    Wondering if there’s a way to remove the inline CSS generated after animating the position of an element with js/jquery…any ideas?

    Thanks

    #148446
    TheDoc
    Member

    You just need to set the style attribute to an empty string. With jQuery:

    $('.selector').attr('style','');
    

    http://codepen.io/ggilmore/pen/ac560d9cab03376629342f24ffc578b5

    #148513
    Kuzyo
    Participant
    #148516
    TheDoc
    Member

    I can’t remember what it was for, but there was a particular case where removeAttr wasn’t working for inline CSS. I forgot what circumstances caused it, but that’s why I just set it to an empty string now. Might have been an old webkit bug? I can’t remember.

    #148523
    Kuzyo
    Participant

    Yepp, found:

    Removing an inline onclick event handler using .removeAttr() doesn’t achieve the desired effect in Internet Explorer 6, 7, or 8. To avoid potential problems, use .prop() instead

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.