我尝试了很多方法来阅读和访问表格元素。我有一个html表,我需要获得PRODUCT列值。但我无法。因为我无法按列值达到列。 你能帮忙吗?我会根据产品名称和日期,差异等等计算一些计算结果。谢谢。
<table id="playsql-0" class="playsql tablesorter" data-uid="0" data-query-editor-url="/confluence/playsql-base-plugin/query-editor.action?key=PDOQA&queryId=35">
<tbody class="">
<tr id="playsql-0-7" data-row-id="7">
<th class="id-column" data-position="7" data-row-id="7">7</th>
<td class="data-cell" data-editor-value="19502">19502</td>
<td class="data-cell" data-editor-value="7">7</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtmemutlu">dtmemutlu</td>
<td class="data-cell" data-editor-value="Completed">Completed</td>
<td class="data-cell" data-editor-value="Interruptive Work">Interruptive Work</td>
<td class="data-cell" data-editor-value="Planned">Planned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="2014-07-16 07:00:00">2014-07-16 07:00:00</td>
<td class="data-cell" data-editor-value="2014-07-16 07:50:00">2014-07-16 07:50:00</td>
<td class="data-cell" data-editor-value="2014-07-16 07:00:00">2014-07-16 07:00:00</td>
<td class="data-cell" data-editor-value="2014-07-16 07:45:00">2014-07-16 07:45:00</td>
<td class="data-cell" data-editor-value="CRM">CRM</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="45">45</td>
</tr>
<tr id="playsql-0-5" data-row-id="5">
<th class="id-column" data-position="5" data-row-id="5">5</th>
<td class="data-cell" data-editor-value="19503">19503</td>
<td class="data-cell" data-editor-value="8">8</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtmemutlu">dtmemutlu</td>
<td class="data-cell" data-editor-value="Completed">Completed</td>
<td class="data-cell" data-editor-value="Interruptive Work">Interruptive Work</td>
<td class="data-cell" data-editor-value="Planned">Planned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="2014-07-11 07:20:00">2014-07-11 07:20:00</td>
<td class="data-cell" data-editor-value="2014-07-11 07:50:00">2014-07-11 07:50:00</td>
<td class="data-cell" data-editor-value="2014-07-11 07:20:00">2014-07-11 07:20:00</td>
<td class="data-cell" data-editor-value="2014-07-11 07:35:00">2014-07-11 07:35:00</td>
<td class="data-cell" data-editor-value="CRM">CRM</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="15">15</td>
</tr>
<tr id="playsql-0-4" data-row-id="4">
<th class="id-column" data-position="4" data-row-id="4">4</th>
<td class="data-cell" data-editor-value="19504">19504</td>
<td class="data-cell" data-editor-value="9">9</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtmemutlu">dtmemutlu</td>
<td class="data-cell" data-editor-value="Completed">Completed</td>
<td class="data-cell" data-editor-value="Interruptive Work">Interruptive Work</td>
<td class="data-cell" data-editor-value="Planned">Planned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="2014-07-09 07:30:00">2014-07-09 07:30:00</td>
<td class="data-cell" data-editor-value="2014-07-09 07:45:00">2014-07-09 07:45:00</td>
<td class="data-cell" data-editor-value="2014-07-09 07:30:00">2014-07-09 07:30:00</td>
<td class="data-cell" data-editor-value="2014-07-09 07:39:00">2014-07-09 07:39:00</td>
<td class="data-cell" data-editor-value="CRM">CRM</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="9">9</td>
</tr>
<tr id="playsql-0-3" data-row-id="3">
<th class="id-column" data-position="3" data-row-id="3">3</th>
<td class="data-cell" data-editor-value="19505">19505</td>
<td class="data-cell" data-editor-value="10">10</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtmemutlu">dtmemutlu</td>
<td class="data-cell" data-editor-value="Completed">Completed</td>
<td class="data-cell" data-editor-value="Interruptive Work">Interruptive Work</td>
<td class="data-cell" data-editor-value="Planned">Planned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="2014-07-08 07:00:00">2014-07-08 07:00:00</td>
<td class="data-cell" data-editor-value="2014-07-08 07:50:00">2014-07-08 07:50:00</td>
<td class="data-cell" data-editor-value="2014-07-08 07:00:00">2014-07-08 07:00:00</td>
<td class="data-cell" data-editor-value="2014-07-08 07:50:00">2014-07-08 07:50:00</td>
<td class="data-cell" data-editor-value="CRM">CRM</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="50">50</td>
</tr>
<tr id="playsql-0-2" data-row-id="2">
<th class="id-column" data-position="2" data-row-id="2">2</th>
<td class="data-cell" data-editor-value="19506">19506</td>
<td class="data-cell" data-editor-value="11">11</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtmemutlu">dtmemutlu</td>
<td class="data-cell" data-editor-value="Completed">Completed</td>
<td class="data-cell" data-editor-value="Interruptive Work">Interruptive Work</td>
<td class="data-cell" data-editor-value="Unplanned">Unplanned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="2014-07-03 15:15:00">2014-07-03 15:15:00</td>
<td class="data-cell" data-editor-value="2014-07-03 15:25:00">2014-07-03 15:25:00</td>
<td class="data-cell" data-editor-value="2014-07-03 15:15:00">2014-07-03 15:15:00</td>
<td class="data-cell" data-editor-value="2014-07-03 15:25:00">2014-07-03 15:25:00</td>
<td class="data-cell" data-editor-value="CRM">CRM</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="10">10</td>
</tr>
<tr id="playsql-0-1" data-row-id="1">
<th class="id-column" data-position="1" data-row-id="1">1</th>
<td class="data-cell" data-editor-value="19508">19508</td>
<td class="data-cell" data-editor-value="12">12</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtmemutlu">dtmemutlu</td>
<td class="data-cell" data-editor-value="Completed">Completed</td>
<td class="data-cell" data-editor-value="Interruptive Work">Interruptive Work</td>
<td class="data-cell" data-editor-value="Planned">Planned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="2014-07-02 07:00:00">2014-07-02 07:00:00</td>
<td class="data-cell" data-editor-value="2014-07-02 07:45:00">2014-07-02 07:45:00</td>
<td class="data-cell" data-editor-value="2014-07-02 07:00:00">2014-07-02 07:00:00</td>
<td class="data-cell" data-editor-value="2014-07-02 07:35:00">2014-07-02 07:35:00</td>
<td class="data-cell" data-editor-value="CRM">CRM</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="35">35</td>
</tr>
<tr id="playsql-0-6" data-row-id="6">
<th class="id-column" data-position="6" data-row-id="6">6</th>
<td class="data-cell" data-editor-value="19607">19607</td>
<td class="data-cell" data-editor-value="15">15</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtitesaygivar">dtitesaygivar</td>
<td class="data-cell" data-editor-value="Fixed">Fixed</td>
<td class="data-cell" data-editor-value="Service Interruption">Service Interruption</td>
<td class="data-cell" data-editor-value="Unplanned">Unplanned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="2014-07-15 16:39:00">2014-07-15 16:39:00</td>
<td class="data-cell" data-editor-value="2014-07-15 16:48:00">2014-07-15 16:48:00</td>
<td class="data-cell" data-editor-value="IRIS & Dış CC">IRIS & Dış CC</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="9">9</td>
</tr>
<tr id="playsql-0-10" data-row-id="10">
<th class="id-column" data-position="10" data-row-id="10">10</th>
<td class="data-cell" data-editor-value="19614">19614</td>
<td class="data-cell" data-editor-value="16">16</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtesari">dtesari</td>
<td class="data-cell" data-editor-value="Completed">Completed</td>
<td class="data-cell" data-editor-value="Interruptive Work">Interruptive Work</td>
<td class="data-cell" data-editor-value="Planned">Planned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="2014-07-17 07:00:00">2014-07-17 07:00:00</td>
<td class="data-cell" data-editor-value="2014-07-17 07:50:00">2014-07-17 07:50:00</td>
<td class="data-cell" data-editor-value="2014-07-17 07:00:00">2014-07-17 07:00:00</td>
<td class="data-cell" data-editor-value="2014-07-17 07:20:00">2014-07-17 07:20:00</td>
<td class="data-cell" data-editor-value="CRM">CRM</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="20">20</td>
</tr>
<tr id="playsql-0-9" data-row-id="9">
<th class="id-column" data-position="9" data-row-id="9">9</th>
<td class="data-cell" data-editor-value="19667">19667</td>
<td class="data-cell" data-editor-value="18">18</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtitesaygivar">dtitesaygivar</td>
<td class="data-cell" data-editor-value="Fixed">Fixed</td>
<td class="data-cell" data-editor-value="Service Interruption">Service Interruption</td>
<td class="data-cell" data-editor-value="Unplanned">Unplanned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="2014-07-16 17:37:00">2014-07-16 17:37:00</td>
<td class="data-cell" data-editor-value="2014-07-16 19:21:00">2014-07-16 19:21:00</td>
<td class="data-cell" data-editor-value="OTT">OTT</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="104">104</td>
</tr>
<tr id="playsql-0-11" data-row-id="11">
<th class="id-column" data-position="11" data-row-id="11">11</th>
<td class="data-cell" data-editor-value="19668">19668</td>
<td class="data-cell" data-editor-value="19">19</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtitesaygivar">dtitesaygivar</td>
<td class="data-cell" data-editor-value="Fixed">Fixed</td>
<td class="data-cell" data-editor-value="Service Interruption">Service Interruption</td>
<td class="data-cell" data-editor-value="Unplanned">Unplanned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="2014-07-17 08:00:00">2014-07-17 08:00:00</td>
<td class="data-cell" data-editor-value="2014-07-17 10:44:00">2014-07-17 10:44:00</td>
<td class="data-cell" data-editor-value="ADK">ADK</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="164">164</td>
</tr>
<tr id="playsql-0-12" data-row-id="12">
<th class="id-column" data-position="12" data-row-id="12">12</th>
<td class="data-cell" data-editor-value="19669">19669</td>
<td class="data-cell" data-editor-value="20">20</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtitesaygivar">dtitesaygivar</td>
<td class="data-cell" data-editor-value="Fixed">Fixed</td>
<td class="data-cell" data-editor-value="Service Interruption">Service Interruption</td>
<td class="data-cell" data-editor-value="Unplanned">Unplanned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="2014-07-17 08:00:00">2014-07-17 08:00:00</td>
<td class="data-cell" data-editor-value="2014-07-17 09:20:00">2014-07-17 09:20:00</td>
<td class="data-cell" data-editor-value="ADK">ADK</td>
<td class="data-cell" data-editor-value="100">100</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="80">80</td>
</tr>
<tr id="playsql-0-13" data-row-id="13">
<th class="id-column" data-position="13" data-row-id="13">13</th>
<td class="data-cell" data-editor-value="19669">19669</td>
<td class="data-cell" data-editor-value="20">20</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtitesaygivar">dtitesaygivar</td>
<td class="data-cell" data-editor-value="Fixed">Fixed</td>
<td class="data-cell" data-editor-value="Service Interruption">Service Interruption</td>
<td class="data-cell" data-editor-value="Unplanned">Unplanned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="2014-07-17 08:00:00">2014-07-17 08:00:00</td>
<td class="data-cell" data-editor-value="2014-07-17 09:20:00">2014-07-17 09:20:00</td>
<td class="data-cell" data-editor-value="IRIS & Dış CC">IRIS & Dış CC</td>
<td class="data-cell" data-editor-value="100">100</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="80">80</td>
</tr>
<tr id="playsql-0-8" data-row-id="8">
<th class="id-column" data-position="8" data-row-id="8">8</th>
<td class="data-cell" data-editor-value="19671">19671</td>
<td class="data-cell" data-editor-value="21">21</td>
<td class="data-cell" data-editor-value="Service Availibility">Service Availibility</td>
<td class="data-cell" data-editor-value="dtitesaygivar">dtitesaygivar</td>
<td class="data-cell" data-editor-value="Fixed">Fixed</td>
<td class="data-cell" data-editor-value="Service Interruption">Service Interruption</td>
<td class="data-cell" data-editor-value="Unplanned">Unplanned</td>
<td class="data-cell" data-editor-value="Minor">Minor</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="2014-07-16 11:00:00">2014-07-16 11:00:00</td>
<td class="data-cell" data-editor-value="2014-07-17 12:59:00">2014-07-17 12:59:00</td>
<td class="data-cell" data-editor-value="OTT">OTT</td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="nul"><span class="not-a-value">-</span></td>
<td class="data-cell" data-editor-value="1559">1559</td>
</tr>
</tbody>
<thead><tr class="sortableHeader">
<th data-editor-value="ID" title="ID" data-column_label="" data-renderer_key="id-renderer" data-column="0" class="sortableHeader"><div class="tablesorter-header-inner"><a href="/confluence/playsql-base-plugin/query-editor.action?key=PDOQA&queryId=35"> </a></div></th>
<th data-editor-value="ISSUE_ID" title="ISSUE_ID" data-renderer_key="read-only-default-renderer" data-column="1" class="sortableHeader tablesorter-headerSortDown"><div class="tablesorter-header-inner">ISSUE_ID</div></th>
<th data-editor-value="ISSUENUM" title="ISSUENUM" data-renderer_key="read-only-default-renderer" data-column="2" class="sortableHeader"><div class="tablesorter-header-inner">ISSUENUM</div></th>
<th data-editor-value="PROJECT" title="PROJECT" data-renderer_key="string-renderer" data-column="3" class="sortableHeader"><div class="tablesorter-header-inner">PROJECT</div></th>
<th data-editor-value="REPORTER" title="REPORTER" data-renderer_key="string-renderer" data-column="4" class="sortableHeader"><div class="tablesorter-header-inner">REPORTER</div></th>
<th data-editor-value="RESOLUTION" title="RESOLUTION" data-renderer_key="string-renderer" data-column="5" class="sortableHeader"><div class="tablesorter-header-inner">RESOLUTION</div></th>
<th data-editor-value="ISSUE_TYPE" title="ISSUE_TYPE" data-renderer_key="string-renderer" data-column="6" class="sortableHeader"><div class="tablesorter-header-inner">ISSUE_TYPE</div></th>
<th data-editor-value="INTERRUPTION_TYPE" title="INTERRUPTION_TYPE" data-renderer_key="string-renderer" data-column="7" class="sortableHeader"><div class="tablesorter-header-inner">INTERRUPTION_TYPE</div></th>
<th data-editor-value="SEVERITY" title="SEVERITY" data-renderer_key="string-renderer" data-column="8" class="sortableHeader"><div class="tablesorter-header-inner">SEVERITY</div></th>
<th data-editor-value="PLANNED_START_DATE" title="PLANNED_START_DATE" data-renderer_key="read-only-default-renderer" data-column="9" class="sortableHeader"><div class="tablesorter-header-inner">PLANNED_START_DATE</div></th>
<th data-editor-value="PLANNED_END_DATE" title="PLANNED_END_DATE" data-renderer_key="read-only-default-renderer" data-column="10" class="sortableHeader"><div class="tablesorter-header-inner">PLANNED_END_DATE</div></th>
<th data-editor-value="REAL_START_DATE" title="REAL_START_DATE" data-renderer_key="read-only-default-renderer" data-column="11" class="sortableHeader"><div class="tablesorter-header-inner">REAL_START_DATE</div></th>
<th data-editor-value="REAL_END_DATE" title="REAL_END_DATE" data-renderer_key="read-only-default-renderer" data-column="12" class="sortableHeader"><div class="tablesorter-header-inner">REAL_END_DATE</div></th>
<th data-editor-value="PRODUCT" title="PRODUCT" data-renderer_key="string-renderer" data-column="13" class="sortableHeader"><div class="tablesorter-header-inner">PRODUCT</div></th>
<th data-editor-value="NUMBER_OF_CLIENTS" title="NUMBER_OF_CLIENTS" data-renderer_key="string-renderer" data-column="14" class="sortableHeader"><div class="tablesorter-header-inner">NUMBER_OF_CLIENTS</div></th>
<th data-editor-value="COST" title="COST" data-renderer_key="string-renderer" data-column="15" class="sortableHeader"><div class="tablesorter-header-inner">COST</div></th>
<th data-editor-value="DIFF_MINUTES" title="DIFF_MINUTES" data-renderer_key="read-only-default-renderer" data-column="16" class="sortableHeader"><div class="tablesorter-header-inner">DIFF_MINUTES</div></th>
</tr></thead><thead>
</thead></table>
答案 0 :(得分:1)
您可以使用jQuery&#39; data()
来获取每个data-*
属性。
或者您可以使用text()
来检索元素的值。
以下是一个示例:
// Iterate through every table row
$("tr").each(function(){
// Iterate through each table data within row
$(this).find("td").each(function(){
// Get the values
var data_value = $(this).data("editor-value");
var data_text_value = $(this).text();
});
});
答案 1 :(得分:0)
另一个小实现:
$("table tr").each(function(){
var currentTr = $(this).children()
var productTd = currentTr[13]; //product column number
console.log("Product: ",$(productTd).attr("data-editor-value"));
});