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,639
  • 2
  • 25
  • 43

6 Answers6

4

Try

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

removeAttr

Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
1

Try this code:

$('*').removeAttr( "style" );
Rich
  • 5,603
  • 9
  • 39
  • 61
1

you could also do:

document.getElementsByTagName("*").removeAttribute("style")
Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162
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
  • 684
  • 9
  • 22
1

With javascript:

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

With jQuery (my personal choice):

$('*').removeAttr('style');
Jai
  • 74,255
  • 12
  • 74
  • 103
0

Yes, try

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

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

rahulbehl
  • 2,629
  • 1
  • 12
  • 6