回答
试试这个:
$content = $('#your_cell_id_here').html();
if($content == '')
{
// yes it is empty
}
else
{
// no it is not empty
}
您可以使用CSS选择器与$
函数获取细胞的元素的引用,然后使用html
功能,看是否有任何内容。例如,如果该小区有ID为“foo”:
if ($("#foo").html()) {
// The cell has stuff in it
}
else {
// The cell is empty
}
谢谢。但所有这些只适用于IE而非Firefox。我现在检查了它。 – Yaswanth 2009-12-22 12:06:20
经过测试,适用于IE7,FF3.5,Chrome3,Safari4和Opera10。测试页面:http://pastie.org/753004预期输出:“foo的内容/栏为空”确保允许空格;你可能想修剪'html'返回的字符串。 – 2009-12-22 12:24:31
你可以CSS类添加到您的table
及其行和列,然后使用jquery selectors得到表项目:
if (!($('#mytable tr.row-i td.column-j').html())) { alert("empty"); }
你什么意思是空的。
//cell maycontain new lines,spaces,&npsp;,... but no real text or other element
$("cellselector").text().trim()=="";
或
//cell has no child elements at all not even text e.g. <td></td>
$("cellselector:empty")
你可以使用我张贴在这里
http://www.keithrull.com/2010/06/09/HowToChangeTableCellColorDependingOnItsValueUsingJQuery.aspx
你可以使用这个,如果你已经知道你要检查
小区ID的trechnique$valueOfCell = $('#yourcellid').html();
或者可以在桌子上的单元迭代
$("#yourtablename tr:not(:first)").each(function() {
//get the value of the table cell located
//in the third column of the current row
var valueOfCell = $(this).find("td:nth-child(3)").html();
//check if its greater than zero
if (valueOfCell == ''){
//place action here
}
else{
//place action here
}
});
- 1. 使用JavaScript检查HTML表格单元格是否为空?
- 2. 检查单元格是否为空
- 3. PHP - 检查单元格是否为空
- 4. 检查excel单元格是否为空
- 5. Excel:如何使用VBA检查单元格是否为空?
- 6. JQuery检查表格单元是否为空
- 7. 如何检查Excel单元格值是否有空格... excel 2007
- 8. 使用VBA检查下面的单元格是否为空
- 9. 如果ELSE在Excel中 - 检查单元格是否为空/空
- 10. DataGridView如何检查单元格是否为空?
- 11. 如何检查单元格是否为空?
- 12. 德尔福网格面板检查单元格是否为空
- 13. 检查ng格中的单元格是否为空
- 14. 检查图像是否为重用单元格为空
- 15. 如何检查单元格是否格式化为货币?
- 16. 检查excel中的单元格是否为空或空白
- 17. OSX - 使用多个表格 - 如何检查单元格是否超出
- 18. 使用单元格引用检查空白单元格
- 19. 使用OpenPyXl检查空单元格
- 20. Flex检查数据网格单元是否为空
- 21. 检查一个.csv单元格是否为空
- 22. SSDT:标量值 - 检查单元格是否为空
- 23. 检查合并的单元格是否为空
- 24. 整洁地检查附近的单元格是否为空
- 25. 检查数据库单元格是否为空
- 26. 检查是否GridViewRow单元格在Visual Basic中为空
- 27. 检查datagridview的单元格中的数据是否为空
- 28. VBA检查单元格是否为空 - 收件人Lastrow
- 29. VSTO c#检查一个单元格是否为空
- 30. 如何使用jQuery隐藏空html表格单元格?
相关:http://stackoverflow.com/questions/376081/how-to-get-a-table-cell-value-using-jquery – miku 2009-12-22 11:41:14