javascript - how to remove all style except font-weight using jquery in all elements -
i using nicedit editor in app , users of our website use paste data ms word or other sources, hence ui breaks up, have decided remove formatting html using jquery.
what did removed inline style , class, creating problem removing bold , italics too, want retain it.
is simple way of removing style except bold using jquery.
example :
<div style="color:red; font-size:13px; font-weight:bold;">test div </div>
in above element want as
<div style="font-weight:bold;">test div </div>
i think way store styles want, remove them , set them again.
$('.selector').each(function() { var keepstyle, $el; $el = $(this); keepstyle = { font-weight: $el.css('font-weight'), font-style : $el.css('font-style') }; $el.removeattr('style') .css(keepstyle); })
Comments
Post a Comment