开发者

JQuery :not filter question

开发者 https://www.devze.com 2023-01-30 05:38 出处:网络
We can pass :checked or :hidden to :not filter as follows: :checkbox:not(:checked) Why cannot开发者_C百科 we pass p:hidden to :not filter as follows:

We can pass :checked or :hidden to :not filter as follows:

:checkbox:not(:checked)

Why cannot开发者_C百科 we pass p:hidden to :not filter as follows:

#something:not(p:hidden)

Thanks.


You can. If you could not, then either both paragraphs in this example would come out black or both would be blue, and my test shows that the first is blue and the second is black, which is what I would expect.

<!DOCTYPE HTML>
<html lang=en>
<meta charset=utf-8>
<title>Test</title>
<h1>Testing</h1>
<p id="something">testing</p>
<p id="else" style="display: none">testing</p>
<script src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script>
$('#something:not(p:hidden)').css('color', 'blue');
$('#else:not(p:hidden)').css('color', 'blue');
$('#else').css('display', 'block');
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消