问题描述
您好b $ b
我在表单上创建了一个按钮。当我点击按钮时,会创建一个div面板。这个按钮也在执行它的onclick事件。
我的问题是,onclick事件没有被ShowPanel函数触发/触发()
以下代码如下:
ASP.NET页面:
< script src = http://code.jquery.com/jquery-2.1.1.js > < / script >
< script 类型 = text / javascript >
函数ShowPanel(){
$('#btnSubmit')。trigger('click'); - 调用btnSubmit_Click事件
$('#divcontrol')。toggle(slow);
返回false;
}
< / script >
----创建小div面板并提交按钮---
< div id = divcontrol style = background-color:绿色;边框:2纯红色;宽度:300px;高度:100px;颜色:白色;字体大小:30px;显示:无 >
< / div >
----提交按钮------
& lt; asp:按钮 id = btnSubmit runat = server 文字 = 提交 OnClientClick = javascript:return ShowPanel();
返回false; OnClick = btnSubmit_Click / >
-------------提交按钮的C#Onclick事件---- ---
受保护 void btnSubmit_Click ( object sender,EventArgs e)
{
GetDetails();
}
单击按钮时会创建div面板,但是onclick事件不会被函数触发/触发(ShowPanel())。
有没有办法从函数中激活btnSubmit_Click事件(ShowPanel()?
Hi
I have a button created on a form. When I click on the button a "div" panel is created. This button is also executing its onclick event.
My problem is, the onclick event is not getting triggered/fired from the function ShowPanel()
Here is the code as below:
ASP.NET Page:
<script src="http://code.jquery.com/jquery-2.1.1.js"></script> <script type="text/javascript"> function ShowPanel() { $('#btnSubmit').trigger('click'); -- Calling the btnSubmit_Click event $('#divcontrol').toggle("slow"); return false; } </script>
----Creating the small div panel and submit button---
<div id="divcontrol" style="background-color: Green; border: 2 solid red;width:300px;height:100px;color:White;font-size:30px; display :none"> </div> ----Submit button------ <asp:Button id="btnSubmit" runat="server" Text="Submit" OnClientClick="javascript:return ShowPanel(); return false;" OnClick="btnSubmit_Click"/>
-------------C# Onclick event for Submit Button-------
protected void btnSubmit_Click(object sender, EventArgs e) { GetDetails(); }
The "div" panel is created when the button is clicked, but the onclick event is not getting fired/triggered from the function (ShowPanel()).
Is there a way how I can fire the btnSubmit_Click event from the function (ShowPanel()?
这篇关于在Jquery中按钮未触发的Onclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!