這是我想要做的。獲取表格行數據td並選擇
在第一行有TDS然後a = the text in the first cell
和b = the selected value of the drop down that the user selected
我怎麼做,因爲我的代碼不能正常工作?
$(document).ready(function() {
var s = $('table td:first').parents('tr');
var a = s.eq(0).text();
var b = s.eq(1).find('option:selected').val();
alert(a + " " + b);
});
<table>
<tbody>
<tr>
<th>ID</th>
</tr>
<tr>
<td>
test
</td>
<td>
<select>
<option value="yes">yes</option>
<option selected="selected" value="no">no</option>
</select>
</td>
</tr>
</tbody>
</table>
查閱這些鏈接希望它可以幫助你... HTTP://stackoverflow.com/questions/5866862/how-to-get-the-data-from- a-row-jquery http://stackoverflow.com/questions/10147971/jquery-getting-values-from-selected-table-row http://forums.asp.net/t/1652535.aspx – 2012-07-31 09:37:26