一、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):替换并返回指定的子节点

相关文章:

  • 2021-11-14
  • 2022-12-23
  • 2021-11-04
  • 2022-02-18
  • 2021-11-30
  • 2022-12-23
  • 2021-09-17
猜你喜欢
  • 2021-08-29
  • 2021-12-17
  • 2021-11-14
  • 2021-11-14
相关资源
相似解决方案