Home > Blockchain >  removeClass('data-element="xxx"'); not working
removeClass('data-element="xxx"'); not working

Time:05-15

I have html code like this:

<div  data-smt="41" data-element="do">

how I can remove this special attribute [data-element]? I trying like this, but not working:

removeClass('data-element="do"');
removeClass('[data-element="do"]');
removeClass('[data-element]="do"');

I suspect a syntax error, am I right? it should be simple, but my strong point is PHP, not JS. Thx for help.

CodePudding user response:

I think removeAttribute function may work for you.

document.querySelector('[data-element="do"]').removeAttribute('data-element')

will remove the attribute data-element.

  • Related