Javascript 如何使用jquery选择器查找特定类的表

Javascript 如何使用jquery选择器查找特定类的表,javascript,jquery,Javascript,Jquery,如何使用jquery选择器仅选择一个具有d类的表。由于某些原因,此代码无法正常工作 var dTableTags = $(".d table"); 示例表是 <table id="thetable" class="d"> <thead> <tr><th>Column 1 header</th><th>Column 2 header</th></tr> </thead>

如何使用jquery选择器仅选择一个具有d类的表。由于某些原因,此代码无法正常工作

var dTableTags = $(".d table");
示例表是

<table id="thetable" class="d">
  <thead>
    <tr><th>Column 1 header</th><th>Column 2 header</th></tr>
  </thead>
  <tbody>
    <tr><td>Column 1 data</td><td>Column 2 data</td></tr>
  </tbody>
</table>

第1列标题第2列标题
第1列数据第2列数据

您的选择器错误;试试
$(“table.d”)


没有直接解释这一点,它遵循的是更全面的。

您正试图搜索d类中的表 这是错误的

将选择器更改为此

$("table.d");   // Because the table has the class d

谢谢我正在学习jQuery并找出选择器。我已经知道了如何得到d类的th/td/tr,但不是桌子。老实说,这里面有一些猜测。在我看来,我想选择d类的所有元素,然后从该列表中选择关联的表:\