简体   繁体   中英

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?

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.

This css should work.

"span#u_0_10 a"

$('#u_0_10> a')。each(function(){//做你的工作});

由于没有人点击链接,所以我会做

$('#u_0_10 > a').trigger("click")

try this code

For particular span with id myId

  $('#myId a').click(function() {
   / process click event here
 });

For all the span with css myKlass

 $('.myKlass a').click(function() {
   / process click event here
 });

For All the span

 $('span a').click(function() {
   / process click event here
 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM