? ?? ?? ??? ?? ??? ?????? ????? ??? ??? ??? ??? ???? ?? ????.
ringa_lee
$(function(){
//???? ??? ? ???? ?????
})
? ?? ?? ??? ???? ???? ?? ????? DOM? ???? ????. ??? ???? ????
????? js ??? <head></head>
里面,
第一種寫法執(zhí)行的時(shí)候,頁面還沒加載完,所以找不到$(".table tr:odd")
selector? ?????.
? ?? ??? ???? ??? ?? ????? ???? ??? ??? ? ????.
? ?? ??? ????? ??? ?? js ??? ?????.
? ?? ?? ????? ?? ?? ? ??? ??? ???? ???? ?? ??? ?? ? ?? ?? ??? ?? ? ????.
? ?? ?? ??? ??? ???? ?? ??? ??? ??? ??? ???? ????. ??? ?? ???? ?? ??? ???? ??? ??? ??? ?? ? ???? ?? ??? ??????.
???
? ??? ???? DOM? ???? ??? ? $(".table tr:odd")
?? ???? ? ?? ??? ???? ? ? ??? ? ?? ????? ??? ??? ? ??? ????.
?? JS
代碼或引入的 JS
文件放在頁面底部,<BODY>
? ??? ?? ?????.
? ?? ?? ??? 1? ??? ????, .table ?? ?? ???? DOM? ???? ?? ???? $ ???? DOM? ?? ??? ??? ?? ? ?? ??? ????. ???????.
? ???? jquery ?? ??? ???? ?? ????. ???? jquery ?? ????? ? ? ???? ?? ??? ?? ? ????
http://www.css88.com/jqapi-1. ...
1. ? ?? ?? ??? ?? ??? ???? ??? ? ???? ????. ?, HTML? ???? ?? ?? .table tr:odd? ???? ???? js ????? ?? ??? ???? ? ? ???? ???? ????. ?? ??? ???? ?????. ??? ???? ?? ??? ???? ?? 0
2.$(function(){})? ?? ?????. ?, ?? ???? ???? ?? html? ??? ??? ?????. ??? ??? html? ???? js? ?????. ???? ??? ? ?? ? ??? ??????
???? ????: http://www.w3school.com.cn/h.asp
? ?? ?? ??:
tableColor();//Alert(0)? ???? "0"? ??? DOM? ???? ?? ??? ? ?? ?????
? ?? ?? ??: ??? ??? ? ??
$(function() {
})
????? js ??? ?? ??? ???? ???, ?? ?? ? js ??? ????? ?? ?? html? ?? js? $(function() {})? ??????. ??