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="NTgw" data-dialog-larg='740' data-dialog-title="dGVzdCBkaWFsb2c=" 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!