如何使用jQuery计算表中的行数?
示例
<html>
<head>
<title>table</title>
<style type="text/css">
table,th,td {
border:2px solid black;
margin-left:400px;
}
h2 {
margin-left:400px;
}
button {
margin-left:400px;
}
</style>
<script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("button").click(function () {
var rowcount = $('table tr').length;
alert("No. Of Rows ::" +rowcount);
});
});
</script>
</head>
<body>
<div>
<h2>HTML TABLE</h2>
<table>
<tr>
<th>
NAME
</th>
<th>
AGE
</th>
</tr>
<tr>
<td>DD</td>
<td>35</td>
</tr>
<tr>
<td>SB</td>
<td>35</td>
</tr>
<tr>
<td>AD</td>
<td>5</td>
</tr>
<tr>
<td>AA</td>
<td>5</td>
</tr>
</table>
<button type="button" id="btn">Click Here</button>
</div>
</body>
</html>热门推荐
10 锡婚祝福语简短霸气
11 国庆中秋祝福语简短搞笑
12 身体康复的祝福语简短
13 高考前祝福语简短字句
14 长辈钻石婚祝福语简短
15 对离岗同事祝福语简短
16 娃娃考试祝福语幽默简短
17 新年给妹妹祝福语简短
18 圣诞祝福语简短小学