更新时间:2023-12-03 08:06:22
Hiya : http://jsfiddle.net/f6FJ3/19/
触发原因请阅读: jQuery:trigger click()无效?
重要的是要澄清jQuery('#open')。click()不会执行href属性锚定标记,因此您不会被重定向。它执行未定义的#open的onclick事件。
以下代码将获得窗口单击时打开的窗口的输出。
below code will get the desired output of window getting open on image click.
JQuery代码
$(document).ready(function(){
$('.tmb').click(function(){
var target=$(this).parent().find("a");
$("#debug").text("clicked "+target.text());
//target.triggerHandler('click');
window.open(target.attr('href'));
});
});
希望这有助于,欢呼!