jquery循环表以进行文本比较
在表格中循环不是问题 在表中循环并同时进行比较会给同一行中的其他td分配不同的值,这是一个问题。如何做到这一点jquery循环表以进行文本比较,jquery,text,comparison,Jquery,Text,Comparison,在表格中循环不是问题 在表中循环并同时进行比较会给同一行中的其他td分配不同的值,这是一个问题。如何做到这一点 - going through #tblView tbody tr.class - to find through all row for second td and see whether the .text() is "completed" - if yes - then third
- going through #tblView tbody tr.class
- to find through all row for second td and see whether the .text() is "completed"
- if yes
- then third td's span's inner text set to "bingo"
- else
- do nothing
- end
<table id="tblView">
<tbody>
<tr class="class">
<td>completed</td>
<td></td>
<td></td>
</tr>
<tr class="class">
<td>not yet</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
-正在通过#tblView tbody tr.class
-查找第二个td的所有行并查看.text()是否已“完成”
-如果有的话
-然后第三个td的span的内部文本设置为“宾果”
-否则
-无所事事
-结束
完整的
还没有
试试看-
$("#tblView tbody tr.class").each(function() {
if ($(this).find("td:eq(1)").text() === "completed") $(this).find("td:eq(2)").text('bingo');
})
演示-你能发布你的html结构吗?