JavaScript

超轻量级php框架startmvc

jQuery分组选择器简单用法示例

更新时间:2020-08-20 11:24 作者:startmvc
本文实例讲述了jQuery分组选择器简单用法。分享给大家供大家参考,具体如下:<!DOCTYPEhtm

本文实例讲述了jQuery分组选择器简单用法。分享给大家供大家参考,具体如下:


<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>jQuery分组选择器</title>
 <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
 <script type="text/javascript">
 $(function(){
 // 注意:#content.title,.header.title无效
 $('.header, div.title, [title="foot"]').css('backgroundColor','red');
 });
 </script>
</head>
<body>
 <div class="header">header
 <div class="title">title</div>
 </div>
 <hr>
 <div id="content">
 content
 <div class="title">title</div>
 <div class="context">context</div>
 <div class="other">other</div>
 </div>
 <hr>
 <footer title='foot'>footer</footer>
</body>
</html>

这里使用在线HTML/CSS/JavaScript代码运行工具:http://tools.jb51.net/code/HtmlJsRun测试上述代码,可得如下运行效果: