$("p").filter(function(index) { return $("ol",this).length == 0; });jquery中的一段代码$("ol",this)这是什么东西啊?以下是html代码:HelloHow are you?

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/05 09:50:41
$(

$("p").filter(function(index) { return $("ol",this).length == 0; });jquery中的一段代码$("ol",this)这是什么东西啊?以下是html代码:HelloHow are you?
$("p").filter(function(index) { return $("ol",this).length == 0; });
jquery中的一段代码$("ol",this)这是什么东西啊?
以下是html代码:
Hello
How are you?

$("p").filter(function(index) { return $("ol",this).length == 0; });jquery中的一段代码$("ol",this)这是什么东西啊?以下是html代码:HelloHow are you?
$("ol",this)是在this中查找ol元素
$("ol",this).length==0就是查找this中不包含ol的this元素(这里的this是

return $("ol",this).length == 0;是相对filter来说的,如果return $("ol",this).length == 0为true的话保留,return $("ol",this).length == 0是false的话元素被删除
这整句话的意思就是:查找
中不包含的
元素