简体   繁体   English

Jquery 并触发对隐藏按钮的点击

[英]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.

相关问题 jQuery触发点击-请求中没有按钮值 - jQuery trigger click - no button value in request 如果使用jQuery隐藏它,我无法点击ASP:Button? - I can't click on an ASP:Button if it is hidden using jQuery? 用户单击使用Jquery的Enter键时如何触发按钮? - How to trigger the button when user click enter key using Jquery? jQuery触发器单击Webform中的按钮不起作用 - Jquery trigger click on button in webform doesn't work 使用运行时创建的链接来触发ASP.Net中隐藏按钮的单击处理程序 - Using runtime created links to trigger the click handler of a hidden button in ASP.Net html按钮未隐藏在图像按钮单击上 - html button is not becoming hidden on image button click asp.net按钮单击不通过jquery在隐藏字段中触发大量数据 - asp.net button click not firing with large amount of data in hidden field through jquery 通过jQuery slideToggle显示div并通过updatepanel中的隐藏按钮运行服务器代码后,div单击不起作用 - div click not working after showing div by Jquery slideToggle and run server code by hidden button in updatepanel jQuery .remove()或.hide()仅在单击发送按钮后隐藏上载的文件,它将已隐藏/已删除的文件保存在数据库中 - jquery .remove() or .hide() only hide uploaded file after click send button it saves the hidden/removed files in database ASP.NET,jQuery在asp:button上获取隐藏字段值 - ASP.NET, jquery get hidden fields values on asp:button click
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM