簡體   English   中英

jQuery focus()無法正常工作

[英]Jquery focus() not working properly

我在onblur事件中調用了一個JQuery函數,在該函數中,我使用了focus() 但是, JQuery focus()無法正常工作。

<input type="text" name="stdmeas['XXL']" id="XXL_qty" value="<?php echo $XXL;?>" size="5" onblur="return fnqtyCount();" />

function fnqtyCount() {
   if(!$.isNumeric( XXL_qty )) {
        $("#err_msg").text("Please enter the numeric values only.");
        $("#XXL_qty").val('');
        $("#XXL_qty").focus();
        return false;
    }
}

根據我的理解,代碼應如下

function fnqtyCount() {
   if(!$.isNumeric( $("#XXL_qty").val() )) {
        $("#err_msg").text("Please enter the numeric values only.");
        $("#XXL_qty").val('');
        $("#XXL_qty").focus();
        return false;
    }
}
function fnqtyCount() {
      var text = $("#XXL_qty").val();
      if (!$.isNumeric(text)) {
          $("#err_msg").text("Please enter the numeric values only.");
          $("#XXL_qty").val('');
          $("#XXL_qty").focus();
          return false;
      }
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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