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?
基础教程推荐
- npm start 错误与 create-react-app 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
