Vanilla JavaScript version of jQuery .click

Working Example: http://jsfiddle.net/6ZNws/

Html

<a href="https://stackoverflow.com/questions/7556564/something">CLick Here</a>
<a href="https://stackoverflow.com/questions/7556564/something">CLick Here</a>
<a href="https://stackoverflow.com/questions/7556564/something">CLick Here</a>

Javascript:

var anchors = document.getElementsByTagName('a');
for(var z = 0; z < anchors.length; z++) {
    var elem = anchors[z];   
    elem.onclick = function() {
        alert("hello");
        return false;
    };
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)