• jquery类选择器无法取得对象问题原因


    <html>
        <script type="text/javascript" src="jquery-1.9.1.js"></script>
    <body>
    
    <table>
    <tr class="bottom b-fffdee xinghao68">
                <td> </td>
                <td class="t-left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="http://localhost:8080/BNCAR2/partsDetailAction?id=58" class="fc-blue"><img src="picture/parts/2014/1/13/138961178380789969.jpg" width="44" height="44" /> 单件商品2</a></td>
                <td></td>
                 <td>            
                    </td> 
                <td></td>
                <td></td>
              </tr>
              
              <tr class="bottom b-fffdee xinghao68">
                <td> </td>
                <td class="t-left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="http://localhost:8080/BNCAR2/partsDetailAction?id=55" class="fc-blue"><img src="picture/parts/2014/1/9/138924733778756518.jpg" width="44" height="44" /> QQQQ</a></td>
                <td></td>
                 <td>            
                    </td> 
                <td></td>
                <td></td>
              </tr>
              
              <tr class="bottom b-fffdee xinghao68" >
                <td> </td>
                <td class="t-left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="http://localhost:8080/BNCAR2/partsDetailAction?id=45" class="fc-blue"><img src="picture/parts/none.jpg" width="44" height="44" /> aa</a></td>
                <td></td>
                 <td>            
                    </td> 
                <td></td>
                <td></td>
              </tr>
              </table>
    </body>
    
    <script type="text/javascript">
        $(function(){
                alert("AAA:"+$(".xinghao68"));
                alert("BBB:"+$(".xinghao68").length);
                $(".xinghao68").each(function(){
                        alert($(this).text());
                        
                    });
            
            });
    </script>
    
    </html>

    如果TR行class写成:<tr class="bottom b-fffdee" class="xinghao68">,这样通过类选择器是取不到的,需要注意代码结构的严谨性~!!!
    应用:在商城类网站购物车中,组合产品下面还有子产品,在移出组合产品的时候需要同时将子产品移出,可以通过设置一个class来获取一个集合,each遍历移出每一个达到效果。

  • 相关阅读:
    [转载]游戏外挂原理
    python cookbook
    RF user guide
    测试理论-selenium的工作原理
    测试理论- the conten of test plan
    测试理论--branch testing and boundary testing
    测试理论--向高级出发
    fiddler安装及配置
    python 面试题: 列表表达式
    [redis]如何将redis设置成diango的cache backend
  • 原文地址:https://www.cnblogs.com/simpledev/p/3522607.html
Copyright © 2020-2023  润新知