gpt4 book ai didi

javascript - A-tag 中的 Fire Click 事件

转载 作者:行者123 更新时间:2023-11-29 17:21:00 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Can I call jquery click() to follow an <a> link if I haven’t bound an event handler to it with bind or click already?

我写了下面的代码。

<div style="background-color:orange">Click me to open the link
<br>
<a target="_blank" href="http://example.com">Link</a>
</div>

<script>
jQuery('div').click(function(){
jQuery('a').click();
});

jQuery('a').click(function(e){
alert('It came here!');
e.stopPropagation();
return true;
});
</script>

但是链接打不开

更新:向 A 标签添加了目标属性。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com