Hello,
I am trying to understand better events:
(function(){
var self = TestEvent = {
element: '',
doSomething: function(e){
self.element = this;
e.stopPropagation()
alert(self.element);
return false;
},
}
var myElements = getElementsByClassName('test-elements');
for (var k in myElements) {
myElements[k].addEventListener("click", TestEvent.doSomething , false);
}
})();
When a link is clicked that triggers the “click” event, the element is alerted BUT the browser follows the link, as if the “return false” was not working.
-
What could cause this? What am I missing?
-
I feel like my code is poorly designed. Could someone be kind enough to tell how to refactor such a simple snippet (so I dont find myself caught once the code gets more complicated).