DDR DDR - 6 months ago 13
HTML Question

Finding anchor inside span element

I have this code in my html

<span id="u_0_10">You can also <a rel="my_Feed" href="#" ajaxify="send_notify?Qid=10&amp;part=99">feed</a>Send me this feed</span>


I want to know can I find that anchor with jQuery and fire its onclick in jQuery?

Answer

You can do it like this,

Live Demo

$('#u_0_10 a').click(function(){
   alert($(this).text()); 
});

$('#u_0_10 a').click();

You can learn more about jQuery selectors and click event here.

Comments