[英]want to clear textbox + focus textbox + prevent asp.net postback on the same button
I have this simple html button on ASP.NET, and on button click I want to clear textbox1, focus on textbox1 and prevent postback as well. 我在ASP.NET上有这个简单的html按钮,按下按钮我想清除textbox1,专注于textbox1并防止回发。 How can I do this?
我怎样才能做到这一点? Preventing postback also stops button's ability to clear and focus.
防止回发也会停止按钮清除和聚焦的能力。 Thanks.
谢谢。
$("#button1").click(function () {
var text1 = $("#textbox1").val();
$.connection.moveshapehub.server.sendmessage1(text1); //send text to hub
//want to clear textbox1 + focus on textbox1
return false; //prevent asp.net postback
});
$("#button1").click(function (e) {
e.preventDefault();
var text1 = $("#textbox1").val();
$.connection.moveshapehub.server.sendmessage1(text1); //send text to hub
//want to clear textbox1 + focus on textbox1
$("#textbox1").focus().val("");
return false; //prevent asp.net postback
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.