Skip to content

How to remove elements which i find with find() jQuery?

I have an element in which i want to find a specific class and remove those class.


editingElm = `<p><span class="editing-target">hello</span><span class="editing-target">Welcome to this virtual world</span></p>`

 let elements = editingElm.find('.editing-target');// elements= [span,span] with the class

How can i loop over the elements array and remove those classes i found?


Thanks to @Carsten Løvbo Andersen

You can’t do editingElm.find(‘.editing-target’) since based on your code, it’s a string.
you have to do $(editingElm).find(‘.editing-target’) and
editingElm = $(editingElm).find(‘.editing-target’).removeClass(“editing-target”)