PLZ看到下面的代碼:1 2 3javascript(jquery) - 代碼應該在 - > onload或document.ready或pageLoad()?
+1+
$(document).ready(function()
{
//Do Some Stuff Here
alert("document.ready");
});
+2+
//onload = onloadOfDocument;
//or
window.onload = onloadOfDocument;
function onloadOfDocument()
{
//Do Some Stuff Here
alert("onloadOfDocument");
}
+3+
function pageLoad()
{
//Do Some Stuff Here
alert("pageLoadFromJS");
}
的JavaScript或jquery的代碼應該在哪些上面的代碼(哪個更好)?
我的意思是在哪個部分,dom是完全加載的,所以我們沒有任何問題來識別裏面的元素?
我剛剛知道警報(「document.ready」);在onload之前被解僱 - 但有人告訴我document.ready更好!爲什麼?
和pageLoad()函數呢? (它是一個預先定義的函數,或者它只是一個沒有意義的函數)?
++感謝對於A & Q ++
++計算器這是很有幫助的,舒適的面積是最好++
感謝您的回答... – MoonLight 2011-03-29 23:38:16