jquery - Display alert dialog on "a" click doesn't work -
i'm trying id of clicked element using jquery isn't working. jquery code:
<script> $(function(){ $("a.step").click(function(){ var id = $(this).attr('id'); alert(id); }); }); </script>
and 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 wrong in code?
update
i don't know cause out <script>...</script>
code out of <body>
tags , write in common.js
, works :-o
you trying id of a-link, aprent li has id. ;)
so try $(this).parent('li').attr('id')
Comments
Post a Comment