表格添加一行并在每行第一列大写字母显示jquery实现方法
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>add_tr</title>
<script src='jquery.js'></script>
<script>
//create letter
var letterArr = [];
for(var i=65,j=0;i<91;i++,j++)
{
letterArr[j] = String.fromCharCode(i);
}
$(function(){
$('#btnok').on('click',function(){
$('table').append('<tr>' + $('table tr:last').html() + '</tr>');
orderLine();
});
orderLine();
});
function orderLine(){
$('input.add').each(function(i){
console.log($(this));
$(this).val(letterArr[i]);
});
}
</script>
</head>
<body>
<input id="btnok" type='button' value="click">
<table border='1' width="400" id="tta">
<tr width="200">
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr width="200">
<td><input type="text" name="add[]" class="add"></td>
<td><input type="text"></td>
<td><input type="text"></td>
<td><input type="text"></td>
<td><input type="text"></td>
</tr>
</table>
</body>
</html>