Jquery触发一次点击 [英] Jquery triggering a click

查看:90
本文介绍了Jquery触发一次点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用jquery来触发点击。

I've been trying to use jquery to trigger a click.

我发现触发点击,如下所示:$(button).trigger('点击);不要关注hrefs。我一直试图通过触发提交按钮来提交ajax,但是没有去。

I've discovered that triggered clicks, like this: $(button).trigger('click'); do not follow hrefs. I've been trying to make an ajax submission by triggering the submit button, but no go.

我知道我可以直接提交。但有没有办法触发按钮?谢谢。

I know I can submit directly. But is there any way of triggering the button? Thanks.

推荐答案

jQuery不会故意触发A元素的原生点击。我不知道为什么。

jQuery does not trigger the native "click" on A elements on purpose. I don't know why.

但你可以使用他们用来触发链接的技术:

But you can use the technique they use to trigger the link yourself:

$link[0].click(); // extract the native DOM element and trigger the click

这是未经测试的,但它是从jQuery源提取的代码,应该工作。

This is untested but it is extracted from jQuery source code and should work.

这篇关于Jquery触发一次点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆