还有一个未捕获的TypeError: undefined不是函数

Yet another Uncaught TypeError: undefined is not a function

本文关键字:undefined 函数 TypeError 有一个      更新时间:2023-09-26

这段代码片段有什么问题?我已经看了许多类似的问题,但没有找到任何有用的。

 $('div.editable').live('click', function() {
     editEl = $(this);
     $('#p-editor').hide();
     $(editEl).addClass('editing');
     $('#div-editor').show();
     $('#div-editor textarea').val($(editEl).html());
 });

Chrome开发者控制台显示:

Uncaught TypeError: undefined is not a function   myJavascript.js
(anonymouse function)                             myJavascript.js
fire                                              jquery-1.7.2.js
self.fireWith                                     jquery-1.7.2.js
jQuery.extend.ready                               jquery-1.7.2.js
DOMContentLoaded                                  jquery-1.7.2.js

问题是

jQuery .live() has been removed in version 1.9 onwards.

使用这个

 $('div.editable').on('click', function(){});

如果你将看到jquery文档,它的.live()类别如下。

Categories: Deprecated > Deprecated 1.7 | Events > Event Handler Attachment | Removed