jQuery Remove style attributes from ALL elements

前端 未结 7 530
挽巷
挽巷 2020-12-29 07:52

I know how to remove attribute from a single element, there are already some posts about that:

$(\"div.preview\").removeAttr(\"style\");

Th

7条回答
  •  自闭症患者
    2020-12-29 08:21

    Select the div, select it's children, then add the div back to the collection and remove class.

    $('div.preview').find('[style]').addBack().removeAttr('style')
    // replace addBack with andSelf for older jQuery
    // if you don't want to remove it from the preview div, just leave addBack off.
    

    however it's probably better to fix the editor rather than fix the results in the long run.

提交回复
热议问题