繁体   English   中英

如何使用jquery选择器查找某个类的表

[英]How do I find a table of certain class with jquery selectors

如何使用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>

你的选择器错了; 尝试$("table.d")代替。

jQuery文档没有直接解释这一点,它遵循更全面的W3C CSS选择器文档

您正在尝试搜索类D中的 表格哪个错误..

将选择器更改为此

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM