I have an element in which i want to find a specific class and remove those class.
example
editingElm = `<p><span >hello</span><span >Welcome to this virtual world</span></p>`
let elements = editingElm.find('.editing-target');// elements= [span,span] with the class
editingElm.removeClass('editing-target');
How can i loop over the elements array and remove those classes i found?
CodePudding user response:
Remove class from elements instead of editingElm
editingElm = `<p><span >hello</span><span >Welcome to this virtual world</span></p>`
let elements = editingElm.find('.editing-target');// elements= [span,span] with the class
elements.removeClass('editing-target');
CodePudding user response:
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")
$(editingElm).find('.editing-target').removeClass("editing-target")
