Problem: YUI3 - Onclick event handling for links with the same classes
We have several links on a page with the same class. When I click on one of the links, there are several different actions that should be performed based on the link that the link was clicked on, for example,
<a href="?page=1" data="test1" class="sample">One</a>
<a href="?page=2" data="test2" class="sample">two</a>
<a href="?page=3" data="test3" class="sample">three</a>
handler code:
Y.all('.sample').on('click', function(e){
e.preventDefault();
alert(this.getAttribute("data"));
});
when I click any of the links, I get a list of all the "data" attributes. We need only these links.
source
share