Home › Forums › JavaScript › [Solved] Remove empty class="" from DOM? › Reply To: [Solved] Remove empty class="" from DOM?
January 17, 2018 at 11:30 pm
#265667
andu
Participant
I’m aware this is a very old question, but having to deal with this issue myself, I thought about posting the answer. Maybe it will help others along the way:
for the whole document:
document.body.innerHTML = document.body.innerHTML.replace(/class=””/g, ”);
for a specific element:
myParent.innerHTML = myParent.innerHTML.replace(/class=””/g, ”);
Inspired from:
https://stackoverflow.com/questions/5558613/replace-words-in-the-body-text