2017-11-17 4 views
-1

私はいくつかのフォームとテーブルがある私のWebアプリケーションでhtmlページを持っています。 次の列の[広告ID]は必須です。JQueryを使用してhtmlテーブルの特定の列にあるセルが空であるかどうかをチェックする方法は?

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

上記テーブルの内容を追加します。

[広告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 
    } 
} 

誰でも私にこれを手伝ってもらえますか?

+0

を役に立てば幸い

https://api.jquery.com/eq-selector/参考になっなります私はdownvotingの理由を知っていることはできますか? – sndu

答えて

1

使用jqueryのセレクタ:EQ

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

このリンクは、これが

+0

答えは質問に関連していないようです – sndu

関連する問題