jquery的过滤选择器

对许多的div和h标题 ,可以仅仅选择标题进行样式设计

<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type" content="text/html;charset=gb2312" />

<title>无标题文档</title>

<script type="text/javascript"src="e:/jquery/jquery-1.7.1.min.js"></script>

</head>

 

<body>

<div>11111111</div>

<div>22222222222</div>

<div>333333333333</div>

<div>444444444</div>

<div>555555555</div>

<div>666666661</div>

<h1>www.yyjcw.com</h1>

<h1>www.yyjcw.com</h1>

<script type="text/javascript">

$(function(){

$("div:first").html("<bstyle=\"color:red;font-size:30px\">999999999999999</b>"); //选择第一个div,改变背景色

$(":header").html("<bstyle=\"color:red;font-size:30px\">www.enet.com</b>");  //改变所有标题元素,即含<h1>的

})

</script>

</body>

</html>


内容过滤选择器

<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type" content="text/html;charset=gb2312" />

<title>无标题文档</title>

<script type="text/javascript"src="e:/jquery/jquery-1.7.1.min.js"></script>

</head>

 

<body>

<div>1221111</div>

<div>jquery</div>

<div>www.sina.com</div>

<div><ahref="http://www.baidu.com"> //www.baidu.com</a></div>

<div><ahref="http://www.baidu.com"> //www.baidu.com</a></div>

<hr/>

<divstyle="width:500px;height:30px;"></div>

<div><ahref="http://www.baidu.com">http://www.baidu.com</a></div>

<div>ggggg</div>

<div>hhhhhh</div>

<divstyle="display:none;height:500px;width:800px;">我是隐藏的div</div>

<scripttype="text/javascript">

$(function(){

      //$("div:contains('jquery')").css("background","#ff0000");//改变所有还有文本“jquery”的dib元素,改变背景

            //$("div:empty ").css("background","#ff0000");  //改变不包含子元素的div的背景色

           //$("div:has(a)").css("background","#ff0000"); //选中所有含有a标签的div,改变背景色

          //$("div:parent").css("background","#ff0000");//改变含有子元素的div的背景色

          $("div:hidden").css("background","#ff0000").slideDown();//对隐藏的div样式定义,下拉方式展开div

})

</script>

</body>

</html>




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值