<div class="editor">
<p>Donec id justo. Praesent porttitor, nulla vitae posuere iaculis, arcu nisl dignissim dolor, a pretium mi sem ut ipsum. Curabitur suscipit suscipit tellus. Phasellus gravida semper nisi.</p>
<div class="actions">
<button type="button" class="btn" data-action="save">Save text</button>
<button type="button" class="btn" data-action="close">Close editor</button>
</div>
</div>
const saveBtn = document.querySelector('.editor button[data-action="save"]');
const closeBtn = document.querySelector('.editor button[data-action="close"]');
console.log(saveBtn.dataset.action); //save
console.log(closeBtn.dataset.action); //close
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.