未捕获的TypeError:对象[object Object]没有方法'live'

Fra*_*sca 16 jquery object jquery-validation-engine

得到此错误:

Uncaught TypeError: Object [object Object] has no method 'live'
Run Code Online (Sandbox Code Playgroud)

从这个JavaScript和jQuery代码:

init: function(options) {
  var form = this;
  if (!form.data('jqv') || form.data('jqv') == null ) {
    options = methods._saveOptions(form, options);
    // bind all formError elements to close on click
    $(".formError").live("click", function() {

      //Getting error here:
      //Uncaught TypeError: Object [object Object] has no method 'live'

    });
  }
  return this;
};
Run Code Online (Sandbox Code Playgroud)

为什么方法live丢失了?

Nea*_*eal 32

.live在jquery 1.9 中删除

见DOC:http://api.jquery.com/live/


请尝试使用.on:

$(document).on('click', '.formError', function(){ 
   //your event function
});
Run Code Online (Sandbox Code Playgroud)


Ja͢*_*͢ck 7

根据文档,.live()自1.7以来已被弃用并在1.9中删除.

您可能要降级jQuery或使用更新版本的验证插件(如果可用).