一、筛选
一.1过滤
first():获取匹配的第一个元素
$("#oDiv>ul>li").first().css("border","1px solid blue")
last():获得匹配的最后一个元素
$("#oDiv>ul>li").last().css("border","1px solid blue")
eq(N):获取匹配的第N或-N个元素
$("#oDiv>ul>li").eq(3).css("border","1px solid blue")
filter(selector):筛选出与指定表达式匹配的元素集合
$("#oDiv>#myOl>li").filter("[title=aa]").css("background","yellow");
has(selector):筛选出包含特定特点的元素的集合
$("#oDiv>#myOl>li").has("span").css("background","yellow");
not(selector):筛选出不包含特定特点的元素的集合
$("#oDiv>ul>li").not("[title]").css("background","red");
一.2查找
children():子标签中找
$("#oDiv>ul").children().css("background","orange");
find():后代标签中找
$("#oDiv>#myOl").find("span").css("background","red");
parent():父标签
$("b").parent().css("background","blue");
prevAll():前面所有的兄弟标签
$("#oDiv>ul").children().eq(2).prevAll().css("background","orange");
nextAll():后面所有的兄弟标签
$("#oDiv>ul").children().eq(2).nextAll().css("background","orange");
siblings():前后所有的兄弟标签
$("#oDiv>ul").children().eq(2).siblings().css("background","orange");
append():将内容添加到指定的元素后面
$("#oDiv>li").last().append("<a href = '#'>百度一下</a>");
appendTo():和append()颠倒
$("<a href = '#'>百度一下</a>").appendTo($("#oDiv").children().last());
prepend():将内容添加到指定元素前面
$("#oDiv>li").first().prepend("<a href = '#'>百度一下</a>");
prependTo():和prepend()颠倒
$("<a href = '#'>百度一下</a>").prependTo($("#oDiv").children().eq(2));
after():在匹配元素之后插入内容
$("#oDiv").children().filter("[title=b]").css("background","red").after("<a href = '#'>呵呵</a>");
before():在匹配元素之前插入内容
$("#oDiv").children().filter("[title=b]").before("<a href = '#'>呵呵</a>");
empty():删除匹配的元素集合中所有的子节点(不包含匹配的元素)
$("#oDiv").children("li").css("background","red").empty();
remove():删除匹配的元素集合中所有的子节点(包含匹配的元素)
$("#oDiv").children("li").css("background","red").remove();
replaceWith():将所有匹配的元素替换成指定的内容
$("#oDiv").find('span').css("background","red").replaceWith("<a href = '#'>超链接</a>")