我有列表和循環它的表,我有表是這樣的:我們如何使用js在循環表中獲取隱藏值?
<table class="table table-striped">
<tr>
<td>Hidenfield</td>
<td>Dropdownlist</td>
</tr>
//loop here and have result
<tr>
<td><input type='hiden' value='1' class='myclass'/></td>
<td>
<select id="cateActive" class="activeStatus" name="cateActive">
<option selected="selected" value="1">Active</option>
<option value="0">Deactive</option>
</select>
</td>
</tr>
<tr>
<td><input type='hiden' value='2' class='myclass'/></td>
<td>
<select id="cateActive" class="activeStatus" name="cateActive">
<option selected="selected" value="1">Active</option>
<option value="0">Deactive</option>
</select>
</td>
</tr>
<tr>
<td><input type='hiden' value='3' class='myclass'/></td>
<td>
<select id="cateActive" class="activeStatus" name="cateActive">
<option selected="selected" value="1">Active</option>
<option value="0">Deactive</option>
</select>
</td>
</tr>
</table>
,我有一個jQuery函數是這樣的:
$(document).ready(function(){
$(".activeStatus").change(function(){
var categoryId = $('.myclass').val();
alert(categoryId);
});
});
,當我點擊它有任何下拉列表顯示值爲1,如何在任何dropdownbox上行動以獲得行中的隱藏值?
是的,它爲我工作,謝謝你非常多Satpal –