我還是新來的jQuery,我不知道怎麼就被稱爲jQuery函數內。就緒()工作得很好,但不是外面?jQuery函數裏面只有工作。就緒()
例如,這會工作:
$(document).ready(function() {
$('#field1').click(function() {
$('#result').load('/random_post #post');
});
});
但這不會:DOM樹被創建時,執行
$('#field1').click(function() {
$('#result').load('/random_post #post');
});
http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery解釋了原因。 –