How do I use querySelector with data attribute?

Use the querySelector method to get an element by data attribute, e.g. document. querySelector(‘[data-id=”box1″]’) . The querySelector method returns the first element that matches the provided selector or null if no element matches the selector in the document.

Sizin İçin Seçtik  How do I select an element with querySelector?

Leave a Reply

Your email address will not be published. Required fields are marked *