簡體   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