In my project I've binding events to element by calling SMSLiTe() function. I noticed the function gets unbind if a user via the console removes,change element id or class.
Upon trying addEventListener(event,function), if the user via the console removes, change element id or class. I noticed the the event still bind to the element in a fact that it still works.
Can someone explain to me what is happening between the two. here is my code.
HTML:
<span id="c1">click 1</span><br>
<span id="c2">click 2</span><br>
<span id="c3">click 4</span>
JS
//bind events to an element
function SMSLiTe(e,elem,f){
jQuery(document).on(e,elem,f);
}
$(document).ready(function(){
//SMSLiTe('click','#c1',function(e){
//console.log('working');
//});
var a = document.getElementById('c1');
a.addEventListener('click',function(){
console.log('working...');
});
});