Wednesday, 7 August 2013

Display alert dialog on "a" click doesn't work

Display alert dialog on "a" click doesn't work

I'm trying to get the ID of the clicked element using jQuery but it isn't
working. This is the jQuery code:
<script>
$(function(){
$("a.step").click(function(){
var id = $(this).attr('id');
alert(id);
});
});
</script>
And this is the HTML:
<ul class="circle" id="categories">
<li><a id="option_6" class="step" href="#">Cat2</a></li>
<li><a id="option_7" class="step" href="#">Cat3</a></li>
</ul>
What is wrong in my code?

No comments:

Post a Comment