jQuery选择器

< html >
     < head >
         < script  language = 'javascript'  type = 'text/javascript' src = 'jquery-1.11.1.js' > </ script >
     </ head >
     < body >
         < p >p1 </ p >
         < p >p2 </ p >
         < p >p3 </ p >
         < table >
              < tbody >
              < tr >
                   < td >h1h1 </ td >
                   < td >h1h1 </ td >
                   < td >h1h1 </ td >
                   < td >h1h1 </ td >
                   < td >h1h1 </ td >
              </ tr >
              </ tbody >
         </ table >
         < div  id  =  'default' >hello </ div >
         < div  id  =  'testCss' >hello </ div >
         < div  class  =  'testCss' >hello </ div >
         < div  class  =  'testCss' >world </ div >
         < div  id = 's' >
              < h1 >
                   < label >111 </ label >
              </ h1 >
              < label >1 </ label >
              < label >1 </ label >
         </ div >
        
         < script >
         /**/
              $ ( "p" ) . html ( ) ;
              $ ( "p" ) . val ( ) ;
              $ ( "p" ) . text ( ) ;
              $ ( "p" ) . html ( 'sds' ) ;
              $ ( "div" ) . attr ( "disable" , "true" ) ;
              $ ( "#testCss" ) . css ( "font-size" , "19px" ) ;
              $ ( ".testCss" ) . css ( "color" , "red" ) ;
              $ ( "form *" ) . attr ( "disabled" ,  "true" ) ;  //
              $ ( "#default,.testCss" ) . html ( "" ) ; //sele1,sele2,seleN
              $ ( "tr td" ) . html ( 'change' ) ; //ance desc ancedesc()
              $ ( "#s>label" ) . html ( 'YouHoo' ) ;    //parent > child(pc,p-m-c)
              $ ( "h1+label" ) . html ( 'pre+nex' ) ;   // prev + next(h1l)
              $ ( "h1 ~ label" ) . html ( 'pre+all' ) ; // prev ~ siblings()
         /**/
              $ ( "li:first" ) . css ( "background-color" ,  "red" ) ; //
              $ ( "li:last" ) . css ( "background-color" ,  "red" ) ;
              $ ( "li:eq(3)" ) . css ( "background-color" ,  "#60F" ) ; //li0
              $ ( "li:contains('')" ) . css ( "background-color" ,  "#60F" ) ; //li
              $ ( "li:has('p')" ) . css ( "background-color" ,  "#60F" ) ; //lip
              $ ( "li:hidden()" ) . html ( ) ;
              $ ( "li:visible" ) . css ( "background-color" , "blue" ) ;
              $ ( "li[attribute  = '']" ) . css ( "background-color" , "blue" ) ; //li
              $ ( "li[attribute != '']" ) . css ( "background-color" , "blue" ) ;
              $ ( "li[attribute *= '']" ) . css ( "background-color" , "blue" ) ;
              $ ( "li:first-child" ) . css ( "background-color" ,  "green" ) ; //2ulli
              $ ( "li:last-child" ) . css ( "background-color" ,  "green" ) ; //2ulli     
              function  change ( ) {
                   var  value  =  $ ( "a" ) . html ( ) ;
                   if ( value  ==  '' ) {
                        $ ( "div:hidden" ) . attr ( 'style' , 'display:block' ) ;
                        $ ( "a" ) . html ( "" ) ;
                   } else {
                        $ ( "div" ) . attr ( 'style' , 'display:none' ) ;
                        $ ( "a" ) . html ( "" ) ;
                   }
              }
         /**/
              $ ( "#frmTest :input" ) . addClass ( "bg_blue" ) ;
              $ ( "#frmTest :text" ) . addClass ( "bg_blue" ) ;
              $ ( "#frmTest :password" ) . addClass ( "bg_blue" ) ;
              $ ( "#frmTest :button" ) . addClass ( "bg_blue" ) ;
              $ ( "#frmTest :radio" ) . addClass ( "bg_blue" ) ;
              $ ( "#frmTest :checed" ) . attr ( "disabled" ,  "true" ) ;
              $ ( "#frmTest :checkbox" ) . attr ( "disabled" , "true" ) ;
              // #id input:type
              $ ( "#frmTest input:text" ) . addClass ( "bg_red" ) ;
              $ ( "#frmTest :image" ) . addClass ( "bg_red" ) ;
              $ ( "#frmTest :selected" ) . html ( 'ss' )
         /**/
              $ ( "table" ) . empty ( ) ;
         /**/
              $ ( "table" ) . remove ( ) ;
         </ script >
     </ body >
</ html >
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值