消防Click事件可能重複:
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?在A-標籤
我寫了下面的代碼。
<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>
但鏈接未打開。
UPDATE:將目標屬性添加到A標籤。
看到它在行動http://jsfiddle.net/zZqQs/ –
檢查此http://jsfiddle.net/ZeSdV/5/其工作正常.. – Codegiant
@SandipSarkar它是什麼? –