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

I have html code like this:

<div class="smt" 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.



Solution 1:[1]

I think removeAttribute function may work for you.

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

will remove the attribute data-element.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ugur Kellecioglu