jQuery節點查找方法


一、jQuery的父節點查找方法

$(selector).parent(selector):獲取父節點

$(selector).parentNode:以node[]的形式存放父節點,如果沒有父節點,則返回空數組

$(selector).parents(selector):獲取祖先元素

二、jQuery的兄弟節點查找方法

$(selector).prev() / $(selector).previousSibling():獲取上一個兄弟節點

$(selector).prevAll():獲取之前所用的兄弟節點

$(selector).next() / $(selector).nextSibling():獲取下一個兄弟節點

$(selector).nextAll():獲取之后所有的兄弟節點

$(selector).siblings():獲取所有的兄弟節點

三、jQuery的子節點查找方法

$(selector).children():獲取所有直接子節點

$(selector).childNodes:以node[]的形式存放子節點,如果沒有子節點,則返回空數組

$(selector).firstChild:獲取第一個子節點

$(selector).lastChild:獲取最后一個子節點

$(selector).contents:獲取包含的所有內容,包括空文本

$(selector).removeChild(selector):刪除並返回指定的子節點

$$(selector).replaceChild(selector):替換並返回指定的子節點


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM