3

Need to disable all inline styling of every DOM elements from a html document.

Saw some solution to override inline styles but i need to clear all inline styling. Also may be done with the code formatting but not interested with that also,

Is there a way to do this with JavaScript.

Sobin Augustine
  • 3,363
  • 2
  • 24
  • 42

6 Answers6

4

Try

$('*').removeAttr('style');

removeAttr

Tushar Gupta - curioustushar
  • 56,454
  • 22
  • 99
  • 107
1

Try this code:

$('*').removeAttr( "style" );
Rich
  • 5,417
  • 9
  • 36
  • 58
1

you could also do:

document.getElementsByTagName("*").removeAttribute("style")
Sudhir Bastakoti
  • 97,363
  • 15
  • 155
  • 158
1

for single element or group of element

use

$('elementselector').removeAttr('style');

for removing from entire page

use

$(*').removeAttr('style')

hope this helps...

C M
  • 674
  • 9
  • 21
1

With javascript:

document.getElementsByTagName("*").removeAttribute("style");

With jQuery (my personal choice):

$('*').removeAttr('style');
Jai
  • 72,925
  • 12
  • 73
  • 99
0

Yes, try

$('*').removeAttr( "style" );

as it will remove style attribute from each element of the page.

rahulbehl
  • 2,339
  • 1
  • 11
  • 6