Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Add click event to querySelectorAll js

var deleteLinks = document.querySelectorAll('.delete');

Array.from(deleteLinks).forEach(link => {
    link.addEventListener('click', function(event) {
        if (!confirm(`sure u want to delete ${this.title}`)) {
            event.preventDefault();
        }
    });
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Add #click #event #querySelectorAll #js
ADD COMMENT
Topic
Name
6+4 =