children
英 [?t??ldr?n]? ?美 [?t??ldr?n]??
n.兒童;孩子們(child的複數(shù));膝下;孥
jquery children()方法 語法
作用:children() 方法傳回被選取元素的所有直接子元素。
語法:.children(selector)
#參數(shù):
參數(shù) | 說明 |
selector? ?? | 字串值,包含符合元素的選擇器表達(dá)式。 |
jquery children()方法 範(fàn)例
<!DOCTYPE html> <html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <style> body { font-size:16px; font-weight:bolder; } p { margin:5px 0; } </style> </head> <body> <div> <span>Hello</span> <p class="selected">Hello Again</p> <div class="selected">And Again</div> <p>And One Last Time</p> </div> <script>$("div").children(".selected").css("color", "blue");</script> </body> </html>
#點(diǎn)擊 "執(zhí)行實(shí)例" 按鈕查看線上實(shí)例