使用 jQuery 在页面加载时自动单击按钮元素 [英] Auto-click button element on page load using jQuery

查看:20
本文介绍了使用 jQuery 在页面加载时自动单击按钮元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想在页面加载时自动点击一个按钮元素,我将如何使用 jQuery 来实现这一点?

If I wanted to auto-click a button element on page load, how would I go about this using jQuery?

按钮的html是

<button class="md-trigger" id="modal" data-modal="modal"></button>

对这个主题的任何帮助将不胜感激!提前致谢!

Any help on this topic would be greatly appreciated! Thanks in advance!

推荐答案

您只需像这样使用 jQuery...

You would simply use jQuery like so...

<script>
jQuery(function(){
   jQuery('#modal').click();
});
</script>

使用点击功能自动点击#modal按钮

Use the click function to auto-click the #modal button

这篇关于使用 jQuery 在页面加载时自动单击按钮元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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