jq input輸入框聚焦失焦處理;

jquery處理當input輸入框默認爲0時,聚焦讓其置空;失焦如果爲空時,讓其至0處理;

//這是一個例子 input 輸入框聚焦,失焦,及綁定改變事件;
$("input.totalnum").focus(function() {
      var prs=$(this).val();
      if(prs==0||prs=='0'){
          $(this).val("")
      }
}).blur(function() {
   var prs=$(this).val();
   if(prs==""){
       $(this).val(0)
   }
}).bind('input propertychange', function() {
    /********內容略。。。*****/
});

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章