【问题标题】:How to check whether cells in a particular column of a html table is empty using Jquery?如何使用 Jquery 检查 html 表的特定列中的单元格是否为空?
【发布时间】:2017-11-17 18:03:07
【问题描述】:

我的 Web 应用程序中有一个 html 页面,其中有多个表单和表格。 在下面的列中,“广告 ID”是必须填写的。

<table id="mf-table" class="table table-hover">
<tbody>
<tr>
	<th>File Name</th>
	<th>Duration</th>
	<th>Category</th>
	<th>Comment</th>
	<th>Advert Name</th>
	<th>Advert Id</th>
</tr>

上表内容待补充。

我想检查 Advert Id 列下的所有单元格是否都已填满。如果不是,我想获取相关条目的广告名称。

目前我可以检查表格中是否有内容,如果没有则显示警告。

function saveAdminStatusAndTR(){
     var rowCount = $('#mf-table tr').length;
     if(rowCount == 1){ //case where there is no content in the table
        toastr.error('No media file has been uploaded', 'Approval Status');
     }else if(...){ //one of the cell under advert id is empty
          // Need to show a warning message indicating the advert names 
          where there is no advert id
     }else{
       //my code here
     }
 }

谁能帮我解决这个问题?

【问题讨论】:

  • 我能知道投反对票的原因吗?

标签: javascript jquery html html-table


【解决方案1】:

使用 jquery 选择器:eq

$("table td:eq(POSITION)").each(function(idx) {...});

这个链接会很有帮助https://api.jquery.com/eq-selector/

希望对你有帮助

【讨论】:

  • 答案似乎与问题无关
猜你喜欢
  • 2010-12-29
  • 2017-08-12
  • 2011-10-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-17
相关资源
最近更新 更多