2014-07-22 78 views
-1

這段代碼有什麼問題?我瀏覽了許多類似的問題,但找不到任何有用的東西。另一個Uncaught TypeError:undefined不是函數

$('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 
+5

在我看來,有些東西是未定義的。找出哪些東西是不確定的,並且你有你的答案。 –

+0

我以爲我在用... Maxcot

+1

[.live(events,handler):version棄用:1.7,刪除:1.9](http://api.jquery.com/live/) – undefined

回答

3

問題是

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

使用本

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

代替。

如果您會看到jquery docs.live()類別是類似波紋管。

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

以下是[來源](http://api.jquery.com/live/#live-events)。 – AstroCB

+1

請注意,on的這種用法不會委託事件! – undefined

+0

我認爲只有'delegate'功能。 – Mritunjay

相關問題