jquery how to the the value of id

supposed we have
<a href=# id="5"> hello world </a>

to get the value of id

$('a').each(function(){alert(this.id);});
//5

Advertisements

jquery click() doesn’t work after dom update on ajax call.


<a class="clickme" href=#>clickme</a>


$('a.clickme').click(function(){ alert('hello')});

only work on DOM that already exists. it is not working.if the html above injected on existing DOM.
in this case you have to use.


$('a.clickme').live('click', function(){alert('hello')});

jquery live
jquery events not firing on dynamics