Delete a data- Attribute with JavaScript

September 2025

This is how to remove data- attributes from an HTML element via the element's .dataset in JavaScript

HTML

<div data-check="here" class="toUpdate">
  ping
</div>

Output

ping
JavaScript
const el = document.querySelector(".toUpdate");
console.log(el);
delete el.dataset.check;
console.log(el);

// check the console for the output
end of line