1、find和filter的用法
find表示从子集中选择符合条件的对象;
filter表示从自身过滤出符合条件的对象;
2、源代码
<script type="text/javascript">
$(function(){ // 等待DOM加载完毕.
//lzz:实验find和filter方法,前者是在内部查找符合条件的,后者是过滤自身符合条件的
$("#a1").find("#b1").css("background","red");
$("#a1 div").filter(":eq(1)").css("background","blue");
})
</script>
<div id="a1" style="width:50px;height:50px;clear:both;background:#FC3">
<div id="b1" style="width:10px;height:20px;">b1</div>
<div id="b2" style="width:10px;height:20px;">b2</div>
<div id="b3" style="width:10px;height:20px;">b3</div>
</div>
3、效果图

最后
以上就是传统牛排最近收集整理的关于find和filter的区别的全部内容,更多相关find和filter内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复