jQuery的 - 模拟点击按钮不会触发功能 [英] Jquery - Simulating click button doesn't trigger function

查看:223
本文介绍了jQuery的 - 模拟点击按钮不会触发功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,

所以,我一直在使用Firebug也有一些扩展,我写上创建网站,我经常使用的快捷方式。有一个关于事情,我不明白为什么它不工作或者为什么这是不可能的:

So I have been using firebug and also some extensions I wrote to create shortcuts on website I use often. There's on thing that I don't understand why it doesn't work or why it's not possible:

举例code:

<input type="button" onclick="addNewRow()" id="addRow"/>
//This will add a new row to the current table.
//The function is defined by the website (not my function)

在使用Firebug:

When using firebug:

jQuery("#addRow").click();
//This will simulate the button click, and will automatically add the new row.

在使用谷歌浏览器扩展程序:

When using google chrome extension:

jQuery("#addRow").click();
//It doesn't add the new row.

一旦点击按钮时为什么不能执行扩展的功能,以及为什么萤火运行它有没有问题?

Why can't the extension execute the function once the button click occurs, and why firebug has no issues in running it?

这是正常的吗?这是一个安全功能?还是我做错了什么?

Is this normal? Is this a security feature? or am I doing something wrong?

我知道,我不能出于安全原因,网站访问现有的功能,但为什么不会按钮模拟触发一下吗?

I know that I can't access existing functions in a website for security reasons, but why won't the button simulation trigger it for me?

推荐答案

尝试:

jQuery("#addRow").trigger("click");

这篇关于jQuery的 - 模拟点击按钮不会触发功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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