2009-02-26 104 views

回答

9

如果從另一個javascript函數調用它,放下$(document).ready部分

function f1(){ 
$('#idhere').something; 
} 

,或者如果你想調用的函數,只有當文檔準備好,把裏面$(document).ready

$(document).ready(function(){ 
function f1(){ 
    //do something here 
} 
}); 
函數調用

但是,您並沒有充分利用jquery的全部功能。如果您想將onclick事件與元素相關聯,你可以做到這一點,像這樣:

<button id='button1'></button> 

在js文件:

$('#button1').click(function(){ 
//do the onclick sequence here 
}); 
相關問題