views:

79

answers:

1

Here is my html source code:

<ul id="accordion">
 <li><h3><a id="1"></a></h3></li>
 <li><h3><a id="2"></a></h3></li>
 <li><h3><a id="3"></a></h3></li>
</ul>

and javascript

<script type="text/javascript">
 $(document).ready(function(){
  $('#accordion li h3').click(function(){
   //I want to alert the id attribute of a, but i don't know why
   //I tried $(this+'a') or $('#accordion li h3:selected a') but it failed.
  });
 });
</script>
+2  A: 

try

alert($(this).children('a').attr('id'))

cobbal
If you have Firebug or another kind of JavaScript error console (like the developer stuff in Safari), try using console.log instead of alert. Logging stuff to the console requires a lot less clicking :)
mikl