簡體   English   中英

想清除文本框+焦點文本框+阻止asp.net回發同一個按鈕

[英]want to clear textbox + focus textbox + prevent asp.net postback on the same button

我在ASP.NET上有這個簡單的html按鈕,按下按鈕我想清除textbox1,專注於textbox1並防止回發。 我怎樣才能做到這一點? 防止回發也會停止按鈕清除和聚焦的能力。 謝謝。

$("#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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM