How can I erase all inline styles with javascript and leave only the styles specified in the css style sheet?

前端 未结 7 719
一整个雨季
一整个雨季 2020-12-02 14:53

If I have the following in my html:

And this in my c

7条回答
  •  心在旅途
    2020-12-02 15:38

    I was using the $('div').attr('style', ''); technique and it wasn't working in IE8.

    I outputted the style attribute using alert() and it was not stripping out inline styles.

    .removeAttr ended up doing the trick in IE8.

提交回复
热议问题