返回JQ选择器作业...登陆

JQ选择器作业

末幽客2018-12-28 14:08:00280

视频里灭绝老师讲解checked的时候,操作checked需要加上parent()才会生效,但是加上parent会影响到其他含有子元素的标签,老师在视频中只是注释掉了受影响的标签,
并没有介绍如何才能只影响到被check的标签而不影响其他含有子元素的标签,
所以想知道,怎么才能操作check标签而不会影响其他标签,希望老师解答
<!doctype html>

<html>

 <head>

  <meta charset="gbk">

  <title>选择器篇作业</title>

  <script src="jquery-3.3.1.min.js"></script>

 </head>

<style>

*{padding:0;margin:0}

</style>


 <script>

  $(document).ready(function(){

$('input[type][name=shouji]').css('background','pink');//属性选择器

$('div:contains(aaaa)').css('background','pink');//内容选择器

$('#bb ul li').css('list-style','none');//层级选择器


$('#bb ul li:odd').css('background','pink');//顺序选择器


$(":selected").css('background','pink');//表单选择器

$(":checked").parents().css('color','red');

  })

 </script>

 <body>

<div>aaaa</div>

<div id="bb">

<ul>

<li>1</li>

<li>2</li>

<li>3</li>

<li>4</li>

<li>5</li>

</ul>

</div>


<!--属性选择器-->

<form action="">

<lable>姓名<input type="xingming" name='xingming'></lable>

<lable>手机<input type="shouji" name='shouji'></lable>

<select name="city" id="city">

<option>武汉</option>

<option selected>黄石</option>

</select>

<input type="checkbox">11

<input type="checkbox">22

<input type="checkbox" checked>33

</form>

 </body>

</html>


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送