使用'on()'方法进行jquery事件处理

时间:2015-05-26 07:37:07

标签: jquery

我使用jquery ajax动态加载移动号码字段。

<form role="form" id="loginFrm"> 
        <div class="form-signup pb40"> 
           <label>Enter Mobile Number</label>
           <input class="form-signup-input validate mobnum required" maxlength="10" type="text"id="icon_prefix">              
        </div>
</form>

的Javascript

然后,使用on(),

处理按键事件
$(document).on('keypress','.mobnum',function (e) {          
  //if the letter is not digit then display error and don't type anything
    if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
      return false;
    }
});

但我正在使用'文档'搜索目标。这种方法是否正确?如果没有,请提出最佳方法。

0 个答案:

没有答案