Answer the question
In order to leave comments, you need to log in
How to write in "pure" JavaScript the given jQuery example?
How to write it in "pure" JavaScript?
$('.elements div').click(function() {
$(this).remove();
});
Answer the question
In order to leave comments, you need to log in
function pureJSEvent(selector, event, callback) {
var items = document.querySelectorAll(selector);
for(var i=0; i<items.length; ++i)
items[i][event] = callback;
}
pureJSEvent('.elements div', 'onclick', function(){
this.remove();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question