jQuery实现html表格动态添加新行的方法
作者:bea
本文实例讲述了jQuery实现html表格动态添加新行的方法。分享给大家供大家参考。具体实现方法如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta h
本文实例讲述了jQuery实现html表格动态添加新行的方法。分享给大家供大家参考。具体实现方法如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Row example</title>
<script src="jquery-1.6.2.min.js"></script>
<script type="text/javascript">
<!-- jQuery Code will go underneath this -->
$(document).ready(function () {
// Code between here will only run when the document is ready
$("a[name=addRow]").click(function() {
// Code between here will only run
//when the a link is clicked and has a name of addRow
$("table#myTable tr:last").after('<tr><td>Row 4</td></tr>');
return false;
});
});
</script>
</head>
<body>
<table style="width: 100%" id="myTable">
<tr><td>Row 1</td></tr>
<tr><td>Row 2</td></tr>
<tr><td>Row 3</td></tr>
</table>
<a href="#" name="addRow">Add Row</a>
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。
有用 | 无用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Row example</title>
<script src="jquery-1.6.2.min.js"></script>
<script type="text/javascript">
<!-- jQuery Code will go underneath this -->
$(document).ready(function () {
// Code between here will only run when the document is ready
$("a[name=addRow]").click(function() {
// Code between here will only run
//when the a link is clicked and has a name of addRow
$("table#myTable tr:last").after('<tr><td>Row 4</td></tr>');
return false;
});
});
</script>
</head>
<body>
<table style="width: 100%" id="myTable">
<tr><td>Row 1</td></tr>
<tr><td>Row 2</td></tr>
<tr><td>Row 3</td></tr>
</table>
<a href="#" name="addRow">Add Row</a>
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- JQuery判断checkbox是否选中及其它复选框操作方法合集
- window.onload与$(document).ready()的区别分析
- JQuery给网页更换皮肤的方法
- jQuery实现给页面换肤的方法
- js获取滚动距离的方法
- jquery简单实现外部链接用新窗口打开的方法
- Javascript实现div层渐隐效果的方法
- JQuery+CSS实现图片上放置按钮的方法
- Jquery解析json字符串及json数组的方法
- js实现时间显示几天前、几小时前或者几分钟前的方法集锦
- jQuery实现返回顶部效果的方法
- jquery读取xml文件实现省市县三级联动的方法
- Jquery动态添加输入框的方法
- jquery任意位置浮动固定层插件用法实例
- JQuery控制Radio选中方法分析
- 究竟什么是Node.js?Node.js有什么好处?
- js实现发送验证码后的倒计时功能
- JS实现两表格里数据来回转移的方法
- 原生JS和JQuery动态添加、删除表格行的方法