您当前的位置: 首页 >  jquery

[JQ权威指南]第四天:使用jQuery子元素过滤选择器

发布时间:2015-06-16 10:04:35 ,浏览量:0

 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <head> <title>使用jQuery子元素过滤选择器title> <script language="javascript" type="text/javascript" src="jquery-2.1.4.js">script> <style type="text/css"> body { font-size: 12px; text-align: center } ul { width: 241px; list-style-type: none; padding: 0px } ul li { height: 23px; width: 60px; line-height: 23px; float: left; border-top: solid 1px #eee; border-bottom: solid 1px #eee; margin-bottom: 5px } .GetFocus { width: 58px; border: solid 1px #666; background-color: #eee } style> <script type="text/javascript"> //              $(function(){ //增加每个父元素下的第2个子元素类别  //                $("li:nth-child(2)").addClass("GetFocus");  //                })  //              $(function(){ //增加每个父元素下的第一个子元素类别  //                $("li:first-child").addClass("GetFocus");  //              })  //              $(function(){ //增加每个父元素下的最后一个子元素类别  //                $("li:last-child").addClass("GetFocus");  //              })  $(function(){ //增加每个父元素下只有一个子元素类别  $("li:only-child").addClass("GetFocus");       
                }) script> head> <body> <ul> <li>Item 1-0li> <li>Item 1-1li> <li>Item 1-2li> <li>Item 1-3li> ul> <ul> <li>Item 2-0li> <li>Item 2-1li> <li>Item 2-2li> <li>Item 2-3li> ul> <ul> <li>Item 3-0li> ul> body> html> 
关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    105695博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0478s