Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove all attributes from <body> with js or jquery

how to remove all attributes from with js or jquery. (I don't know what is the attributes in the body, i want remove all them)

like image 270
faressoft Avatar asked Aug 29 '10 01:08

faressoft


1 Answers

As of ES2015, you can use Array.from().

const el = document.body;
const attributes = Array.from(el.attributes);
attributes.forEach(attr => el.removeAttributeNode(attr));
like image 184
jabacchetta Avatar answered Oct 14 '22 19:10

jabacchetta