How to call a href by onclick event of a button?(如何通过按钮的onclick事件调用href?)
问题描述
我有以下 a href
我用来打开 jquery 对话框,效果很好.基本上openDialog类已经附上了jquery对话框代码:
I have the following a href
I use to open jquery dialogs, which works fine. Basically, the openDialog class has attached the jquery dialog code:
<a class='openDialog' data-dialog-id='myEditDlg' data-dialog-autosize='false' data-dialog-alt='580' data-dialog-larg='740' data-dialog-title='test dialog' href='/mycontroller/EditDlg/myid'></a>
现在,我想通过按钮的 onclick
事件来调用它.基本上,当我单击按钮时,我希望具有与单击的 <a class='openDialog' href
相同的行为.我该怎么做?**
Now, I'd like to call it by the onclick
event of a button.
Basically, I'd like to have the same behaviour of the clicked <a class='openDialog' href
when I click a button. How can I do it?**
推荐答案
如果我回答你的问题,那么可能是 jQuery trigger()(?) 是你要找的.示例:
If I get you question right then may be jQuery trigger()(?) is what you are looking for. Example:
<button id="bt">Click</button>
<a href="example.com" id="ex">Triggerable link</a>
<script type="text/javascript">
$('#bt').click(function() {
$('#ex').click();
});
</script>
这篇关于如何通过按钮的onclick事件调用href?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何通过按钮的onclick事件调用href?


基础教程推荐
- 每次设置弹出窗口的焦点 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01