是直接转换对象,比如:
$( this ).addClass('c');
$( s[this.i] ).addClass('c');
怎么样一次选择两个然后addClass ?

解决方案 »

  1.   

    jQuery多项选择好象只能都放在引号下面,逗号间隔 $("div,p,span")
    http://jqapi.com/#p=multiple-selector
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $(".c2 li,.c1 li").hover(
         function(){$(this).addClass("hover");},
     function(){$(this).removeClass("hover")}
      )
    })
    </script>
    <style type="text/css">
    .hover{ background:#FF0000;}
    </style>
    </head><body>
    <div class="c1">
       <ul>
          <li>1111111111111111111</li>
      <li>2222222222222222222</li>
      <li>3333333333333333333</li>
      <li>4444444444444444444</li>
      <li>5555555555555555555</li>
       </ul>
    </div><div class="c2">
       <ul>
          <li>1111111111111111111</li>
      <li>2222222222222222222</li>
      <li>3333333333333333333</li>
      <li>4444444444444444444</li>
      <li>5555555555555555555</li>
       </ul>
    </div>
    </body>
    </html>
      

  3.   

    我知道那样可以选择多个元素,我想知道的是直接传入多个dom元素的方法。
      

  4.   


    //这样?
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                var array = ["#aaa",".bbb"];
                for(var a in array){
                    $(array[a]).css("color","red");
                }
            })
        </script>
    </head>
    <body style="text-align:center;">
    <div id="aaa">this is one</div>
    <div class="bbb">this is two</div>
    </body>
    </html>