1var element = document.getElementById("#id");
2element.addEventListener('click', function(){
3 console.log("click");
4});
1document.getElementById("example").addEventListener('click', function() {
2 alert('Click');
3});
1// The anwer of Innocent Ibis is wrong!!
2// It should not have a # for the ID seens we are using getElementById
3var element = document.getElementById("id");
4element.addEventListener('click', function(){
5 console.log("click");
6});
1var element=document.getElementById("some_id");
2var listener=element.addEventListener('click',function(event){
3
4 });
1//with jQuery
2$("#id / .class").on('click', function(){
3 console.log("click");
4});