87,910
社区成员
发帖
与我相关
我的任务
分享
<table id="mytable">
<tr>
<td><input id="P1" name="P1" type="checkbox" checked="true" /></td>
<td><input id="X2" name="X1" type="text" size="5" maxlength="2" /></td>
<td>
<select id="general" name="general" type="select-one">
<option value="0">0:first value</option>
<option value="1">1:second value</option>
<option value="2">2:third value</option>
</select>
</td>
</tr>
<tr><td>....</td><td>....</td><td>....</td><td>....</td></tr>
<tr><td>....</td><td>....</td><td>....</td><td>....</td></tr>
<tr><td>....</td><td>....</td><td>....</td><td>....</td></tr>
</table><input type="button" value="获取修改过的内容" onclick="getModify()" />
<script type="text/javascript" src="http://cdn.bootcss.com/jquery/1.7.1/jquery.min.js"></script>
<script>
$('#mytable :input').each(function () { this.setAttribute('ov', this.type == 'checkbox' ? this.checked : this.value) });
function getModify() {
var arr = [];
$('#mytable :input').each(function () {
if (this.getAttribute('ov') != (this.type == 'checkbox' ? this.checked.toString() : this.value))
arr.push([this.name, this.getAttribute('ov'), this.type == 'checkbox' ? this.checked.toString() : this.value]);
});
alert(JSON.stringify(arr))
}
</script>