日期:2014-05-18  浏览次数:20382 次

JQuery JS 问题
不知道这样的选择器如何表达 望各位高手给解答下

$("#companies tbody tr")这样选择了companies 中 tbody的每一行,假设tr中有多个<td>如下:

<table id="companies" class="display">
 <tbody>
  <tr rel="0">
  <td><input type="checkbox" style="margin:left" /></td>
  <td>Emkay Entertainments</td>
  <td>Nobel House, Regent Centre</td>
  <td>Lothian</td>
  </tr>
 </tbody>
<table>

我现在还是想选择<tr>这样的一行但是不想选这一行中的第一个<td>元素, 不知道该怎么表达了。。。

------解决方案--------------------
JScript code

$(function(){
    $("#companies tbody tr td").each(function(i){
          alert($(this).text());
   });
});

------解决方案--------------------
JScript code
            $("#companies tbody tr td:not(:first)").click(function(){
                alert($(this).html())
            })

------解决方案--------------------
HTML code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>无标题页</title>
    <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
       $(document).ready(function(){
            $("#companies tr").each(function(){
                $(this).find("td").not(":first").click(function(){
                    alert($(this).html())
                })    
            })
       })
    </script>
</head>
<body>
<table id="companies" class="display">
 <tbody>
  <tr rel="0">
  <td><input type="checkbox" style="margin:left" /></td>
  <td>Emkay Entertainments</td>
  <td>Nobel House, Regent Centre</td>
  <td>Lothian</td>
  </tr>
  <tr rel="0">
  <td><input type="checkbox" style="margin:left" /></td>
  <td>Emkay Entertainments</td>
  <td>Nobel House, Regent Centre</td>
  <td>Lothian</td>
  </tr>
 </tbody>
</table>
</body>
</html>

------解决方案--------------------
探讨

HTML code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题页</title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
……

------解决方案--------------------
$(document).ready(function(){
$("#companies tr").each(function(){
$(this).find("td").not(":first").click(function(){
alert($(this).html())
})
})
})
------解决方案--------------------
你想获取哪个td 都行 前提你要给指定的td 加一个样式名 
譬如 定义一个叫SName样式名
 <table id="companies" class="display">
<tbody>
<tr rel="0">
<td><input type="checkbox" style="margin:left" /></td>
<td class="SName">Emkay Entertainments</td>
<td>Nobel House, Regent Centre</td>