First of all I do not want to use jQuery, just pure javascript; please don\'t link to duplicate jQuery posts.
If I have a list like
You can use this:
var link = document.getElementById("bulk");
attachEvent(link, "click", EventHandler);
function attachEvent(element, type, handler) {
if (element.addEventListener) element.addEventListener(type, handler, false);
else element.attachEvent("on"+type, handler);
}
function EventHandler(e) {
console.log(e.target.id);
}
fiddle
This work if li
has children` elements:
fiddle example with children