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?


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: