[英]Jquery and trigger a click on a hidden button
I have a hidden button on a form that I need to click in order to fire an asyncpostback trigger that's attached to an update panel.我在表单上有一个隐藏按钮,我需要单击该按钮才能触发附加到更新面板的 asyncpostback 触发器。
How is this done?这是怎么做的?
$('#myHiddenButton').trigger("click");
Or just要不就
$('#myHiddenButton').click();
See Events/Trigger请参阅事件/触发器
For the Webform: if you set the Visible property to false;对于 Webform:如果您将 Visible 属性设置为 false; typically in .net the control will not be rendered in the HTML output after the page is processed.
通常在 .net 中,处理页面后,控件不会在 HTML 输出中呈现。 Therefore as far as jQuery is concerned, the button does not exist.
因此,就 jQuery 而言,该按钮不存在。
You can do a View Source on the page to verify this.您可以在页面上执行查看源代码来验证这一点。
If you want to do this, instead of using the Visible property, you can do something like:如果要执行此操作,可以不使用 Visible 属性,而是执行以下操作:
<asp:Button ID="HiddenButtonID" runat="server" style="visibility: hidden; display: none;" />
Then you can using jQuery to click button as :然后您可以使用 jQuery 单击按钮为:
$("#HiddenButtonID").click(); //Remember that in button, you must set ClientIDMode = "static"
or要么
$("#<%=HiddenButtonID.ClientID%>").Click();
怎么样
$("#buttonid").click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.