博主信息
博文 36
粉丝 0
评论 1
访问量 34310
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
:jQuery常用的选择器函数
其琛的博客
原创
839人浏览过

代码如下

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery常用选择器函数</title>
<style type="text/css">
ul{
list-style-type: none;
overflow: hidden;
margin: 50px auto;
}
li{

float: left;
background-color: skyblue;
width: 30px;
height: 30px;
border-radius: 50%;
text-align: center;
margin-right: 10px;
}
p{
background-color: skyblue;
width: 50px;
height: 50px;
float: left;
border-radius: 50%;
text-align: center;
line-height: 50px;
}

</style>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#two').hide()
// id选择器
$('.one').css('background-color','red')
// class选择器
$('ul li+p').css('font-size','1.5em')
// 相邻兄弟选择器
$('li:eq(4)').css('background-color','blue')
// 直接选择器
        $('li:first').css('background-color','green') 
        // 选择第一个
        $('[href]').css('color','white')
        // 属性选择器
        

});
</script>
</head>
<body>
<ul>
<li>1</li>
<li>2</li>
<li id="two">3</li>
<li>4</li>
<li>5</li>
<li><a href="">6</a></li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
<p>另类</p>
</ul>
</body>
</html>

样子如图{}3KDE[S3~MFWKZ~%TMVCON.png通过本次作业了解了  一般jQuery的选择器使用,jQuery选择器基于id、类、类型、属性、属性值等进行查找,并且jQuery选择器都是以美元符号$()开始的

批改状态:未批改

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学