2011-10-07 26 views
3
// for example 
$('#text').die('focusout'); 

//then I try to make it live() with a button that just exist 
$('#button').live('click', function(){ 
    $('#text').live('focusout'); 
}); 

當我點擊#button時,螢火蟲告訴我在jQuery.js中有東西在蠕動。如何完成這樣的事情?如何通過jQuery中尚不存在的元素的事件生成元素()

+0

你可以叫'$( '#文本')生活( '事件的內容',函數(){/ .. /});你想隨時隨地',假設jQuery的。被加載。讓它點擊按鈕是沒有意義的。 – artlung

回答

2

live需要您缺少

function liveConvert(type, selector) { 
    return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&"); 
} 

在這裏選擇是不確定的,它失敗的函數的第二個參數。

+0

即使第二個參數,它什麼都不做,腳本太複雜了..謝謝無論如何..:D –

0

你需要一個函數來傳遞的第二個參數到$(「#文本」)生活(「事件的內容」)。如果沒有該回調參數,該行無論如何都沒有任何功能。

試着這麼做:

$('#text').live('focusout', function(){ 
    //do logic here. 
}); 
相關問題