I'm trying to detect click on a pagination anchor through a :data selector with no result:
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
<ul>
<li>
<a href="#" data-pageindex="1">1</a>
</li>
<li>
<a href="#" data-pageindex="2">2</a>
</li>
<li>
<a href="#" data-pageindex="3">3</a>
</li>
</ul>
<script type="text/javascript">
$("a:data(pageindex)").click(function (event) {
event.preventDefault();
alert('anchor clicked!');
})
</script>
</body>
</html>
Any clues about what I am doing wrong?
:dataselector), I think you have to customize your own:dataselector (don't need jQuery UI), check this james.padolsey.com/javascript/… , with the.expr[':'], you can extend many selectors, not just:data.