Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove style from all child elements (including nested)

Tags:

html

jquery

css

I have this code

    $(textObject).children().each(function() {
        $(this).removeAttr('style');
        console.log('removing style from first level element: '+this);

    });

But I want it to affect all nested elements as well, this one only affects first level children. I have also tried

$(this).children().removeAttr('style');

Which doesn't work.

I have also tried

$(this).children().css('font-size','');

which doesn't work either.

It's probably clear what I want to accomplish.

like image 331
Matt Welander Avatar asked Dec 03 '25 04:12

Matt Welander


1 Answers

try

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

Demo Here

like image 58
Vinay Pratap Singh Bhadauria Avatar answered Dec 04 '25 19:12

Vinay Pratap Singh Bhadauria