如何在没有回发的情况下单击按钮执行jQuery? [英] How to execute jquery on button click without postback?
本文介绍了如何在没有回发的情况下单击按钮执行jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是jquery的初学者
我在asp按钮上编写了一个JQuery代码,如下所示
Hi i am beginer for jquery
i wrote a JQuery code on asp button as follows
<script src="JQuery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#btnInsert").click(function(){
alert("Execute");
});
});
</script>
但我的页面正在回发
but my page is getting postback
How can i execute that code without postback?
推荐答案
(document).ready(function(){
(document).ready(function(){
(# btnInsert).click(function(){ alert("Execute"); }); }); < /script >
("#btnInsert").click(function(){ alert("Execute"); }); }); </script>
但我的页面正在回发
如何在不回发的情况下执行该代码?
but my page is getting postback
How can i execute that code without postback?
如果您的按钮#btnInsert是Asp.Net按钮控件,请在设计器中选择按钮,然后查看属性
确保UseSubmitBehavior设置为 False
另外,如果您只想执行客户端脚本,则可以在此处使用标准" html按钮.
If your button #btnInsert is an Asp.Net button control, select the button in the designer and look at the properties
Make sure UseSubmitBehavior is set to False
Alternatively, you can just use a ''standard'' html button here if you just want to execute client script.
这篇关于如何在没有回发的情况下单击按钮执行jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文