获取元素父节点,子节点,兄弟节点,查找元素
$("#test1").parent(); // 父节点
$("#test1").parents(); // 全部父节点(包含多个层级)
$("#test1").parents(".mui-content");//返回class为mui-content的父节点
$("#test1").children(); // 全部子节点
$("#test1").children("#test1"); //返回id为test1的子节点
$("#test1").contents(); // 返回id为test里面的所有内容,包括节点和文本
$("#test1").contents("#test1"); //返回id为test里面的id为#test1的节点和文本
$("#test1").prev(); // 上一个兄弟节点
$("#test1").prevAll(); // 之前所有兄弟节点
$("#test1").next(); // 下一个兄弟节点
$("#test1").nextAll(); // 之后所有兄弟节点
$("#test1").siblings(); // 所有兄弟节点
$("#test1").siblings("#test2"); //返回id为test2的兄弟节点
$("#test").find("#test1"); 选中id为test后代中 id为test1的节点
JQ插入元素的几种方法
1.append() 在被选中元素的“结尾”位置插入内容
2. prepend() 在被选中元素的“开始”位置插入内容
3.appendTo() 把需要的内容添加到选定元素“结尾”
4.after() 方法在被选元素“后”插入指定的内容
5.before() 方法在被选元素“之前”插入内容
如:$("#divId").find(".modal-body").append("<li>hello</li>")
参考文章:
https://www.cnblogs.com/milletHandsome/p/11887833.html
https://blog.csdn.net/sinat_33457233/article/details/52474249