通过li点击点击href上的点击事件

时间:2012-04-16 09:45:23

标签: javascript jquery html triggers

希望通过使用这个小提琴很容易理解:

http://jsfiddle.net/xQ9Nz/13/

它确实“存在”$(“a.editarLocal”,这个),但它不会触发点击事件。

提前致谢!

1 个答案:

答案 0 :(得分:1)

当您的意思是“触发点击”时,您希望链接正常工作吗?你不能。

解决方法是在使用window.location重定向的链接上注册点击事件。

例如:

// Your code somewhere in the onclick of another element
$('#the-link').click()

// Then, register a click event
$('#the-link').on('click', function() {
    window.location.href = this.href
 })

编辑:哎呀,看起来像一位评论者在我提交答案时说了这句话。 @David Hedlund:创建你的答案,我会删除我的:)

相关问题