2017-11-07 13 views
-2

enter image description here各テーブル行

私は、テーブルの各行に隠しフィールドの値を取得したい

、私はこれを行うことができますどのように 、任意の提案が高く評価

に隠しフィールドの値を取得する方法

答えて

0
function ApplyProcessingColor() 
    { 
     $("#xhtml_grid tr").each(function() 
     { 
      var hdnLock=$(this).find("td:first").text(); 
      if(hdnLock=='True') 
      { 
       $(this).css('background-Color','#7FFFD4'); 
      } 
     }); 
    } 

私はあなたの答えを見て、方法を見つけた解決策

1

ここでは、配列を使用した簡単な例を示します。隠された入力値を取得し、それを配列にプッシュしたいだけです。このように

//create hidden fields array 
 
var hiddenFields = []; 
 

 
//for each table row 
 
$("#yourTable tr").each(function() 
 
{ 
 
    //get hidden field value 
 
    var hiddenField = $(this).find("input[type='hidden']").val(); 
 
    
 
    //if not empty push to array 
 
    if(hiddenField !='undefined'&& hiddenField !=null) 
 
    hiddenFields.push(hiddenField); 
 
}); 
 

 
//output all hidden field values stored in array 
 
console.log(hiddenFields);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<table id="yourTable"> 
 
    <tr><th>row id</th><th>column 1</th><th>column 2</th></tr> 
 
    <tr> 
 
    <td><input type="hidden" value="row id 1"> 1 
 
</td><td>row 1</td><td>row 1</td> 
 
    </tr> 
 
    <tr> 
 
    <td><input type="hidden" value="row id 2"> 2 
 
</td><td>row 2</td><td>row 2</td> 
 
    </tr> 
 
    <tr> 
 
    <td><input type="hidden" value="row id 3"> 3 
 
</td><td>row 3</td><td>row 3</td> 
 
    </tr> 
 
</table>

+0

感謝のヨーダを見つけました。! –

関連する問題