Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [Solved] Remove empty class="" from DOM? Reply To: [Solved] Remove empty class="" from DOM?

#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