[color=red][size=x-large]内容选择器[/size][/color]
<script type="text/javascript" src="jquery-1.4.3.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#button1").click(function()
{
//匹配包含给定文本的元素.
//查找所有包含 "test" 的 div 元素
$("div:contains('test')").css("background","red");
});
$("#button2").click(function()
{
//匹配所有不包含子元素或者文本的空元素
//查找所有不包含子元素或者文本的空元素
$("div:empty").css("background","blue");
});
$("#button3").click(function()
{
//匹配含有选择器所匹配的元素的元素
//给所有包含class="mini" 元素的 div 元素添加background
$("div:has('.mini')").css("background","red");
});
$("#button4").click(function()
{
//匹配含有子元素或者文本的元素
//查找所有含有子元素或者文本的 td 元素
$("div:parent").css("background","yellow");
});
$("#button5").click(function()
{
//查找隐藏的 tr
//alert($("div:hidden").length);
$("div:hidden").show(3000).css("background","orange");
});
$("#button6").click(function()
{
//查找所有可见的 tr 元素
//alert($("div:hidden").length);
$("div:visible").show(3000).css("background","orange");
});
});
</script>