通过功能模拟按钮单击事件 [英] Simulate a button click event via a function

查看:81
本文介绍了通过功能模拟按钮单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码:

<button type="button" 
    data-toggle="modal" id="testing" 
    class="btn btn-icon btn-primary glyphicons circle_ok" 
    data-target="#myModal"><i></i>
</button>

我想通过加载页面时执行的功能来模拟点击。

I'd like simulate a click via a function executed when the page is loaded.

我该怎么做?

谢谢,

推荐答案

使用简写方法 .click()

$('your-button-selector').click()

.trigger()

$('your-button-selector').trigger('click')

要模拟点击事件,它将运行所有已注册的点击事件处理程序,但可能/可能不会触发默认操作

To simulate a click event, it will run all registered click event handlers, but may/may not trigger the default action

这篇关于通过功能模拟按钮单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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