如何在jQuery按钮中停止回发 [英] How do I stop postback in jQuery Buttons

查看:81
本文介绍了如何在jQuery按钮中停止回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我按下按钮时,它会闪烁文本,但按钮会重置为原始状态。我希望它在单击按钮时保留在文本上。

我认为它与ASP.net中的runat ='server'有关

如何我是否在jQuery按钮中停止回发?



我试图将AutoPostBack = false添加到Button1无法正常工作

When I press the button it flashes the text but the button resets to its original state. I want it to stay on the text when the button is clicked.
I think it has something to do with "runat='server'" in ASP.net
How do I stop postback in jQuery Buttons?

I tried to add "AutoPostBack=false" to Button1 that did not work

<script type="text/javascript" src="C://Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
      $("#<%= Button1.ClientID %>").on("click", function () {
            $("#<%= Panel1.ClientID %>").fadeToggle(200);
        });
    });
</script>



...


...

<asp:Button ID="Button1" runat="server" Text="Button1" />
<asp:Panel ID="Panel1" style="display:none" runat="server">Toggle Display</asp:Panel>

推荐答案

function (){


#<%= Button1.ClientID%>)。on( 点击 function (){
("#<%= Button1.ClientID %>").on("click", function () {


#<%= Panel1.ClientID%>)。fadeToggle( 200 < /跨度>);
});
});
< / script>
("#<%= Panel1.ClientID %>").fadeToggle(200); }); }); </script>



...


...

<asp:Button ID="Button1" runat="server" Text="Button1" />
<asp:Panel ID="Panel1" style="display:none" runat="server">Toggle Display</asp:Panel>


这篇关于如何在jQuery按钮中停止回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆