Jquery is the best way to remove all classes and all identifiers from div, ul, li, span, a

What is the best way to remove all classes and all identifiers from all div, ul, li, span, a inside a div with id = "remove"?

+7
source share
4 answers

Alternative to other answers using find.

$('#remove').find('div, ul, li, span, a').removeAttr('id').removeAttr('class'); 
+6
source

Here you

 var context = $("div#remove"); $("div, ul, li, span, a", context).removeAttr("class").removeAttr("id"); 
+2
source

Try:

 $("div, ul, li, span, a","#remove").removeClass() 
+2
source

I wrote you a demo, you can check it from there.

http://jsfiddle.net/TxcAB/1/

 $("#remove").click(function(){ $("div,ul,li,a").each(function(){ $(this).removeAttr("id"); $(this).removeAttr("class"); }) }) 
0
source

All Articles