jquery怎么在tabel中添加一个tbody

jquery怎么在tabel中添加一个tbody,第1张

jQuery 添加新内容有以下四个方法:

append() - 在被选元素的结尾插入内容

prepend() - 在被选元素的开头插入内容

after() - 在被选元素之后插入内容

before() - 在被选元素之前插入内容

按你的需求给你修改了一下,不知是否这种效果

<table id="app"></table>

function remove()

{

$("#app>tbody").remove()

}

function add(){

$("#app").append('<tr><td>从<label><input type="text" name="fqty" width="50" />件

--- <input type="text" name="eqty" width="50"

/>件</label></td><td><inputtype="text" name="eqty" width="50" /></td><td><a

href="javascript:void(0)" onclick="remove()">删除</a></td></tr>')

}

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8">

<title>jQuery插入,复制、替换和删除节点</title>

<script type="text/javascript" src="jquery-1.7.js"></script>

<script type="text/javascript">

function onload(){

var $div1=$("<div style=\"background-color:990width:90pxheight:90px\" id='dateOfListParent'></div>")

$("#x").append($div1)

var $div=$("<div id='sijiDateOfList' style='height:90pxwidth:500pxmargin-left:50pxbackground-color:#39F'></div>")

$("#dateOfListParent").append($div)

var $table=$("<table border='1' id='sijitable' style='margin-left:50px'><tr><td>xcccccc</td></tr></table>")

$("#sijiDateOfList").append($table)

var $tr=$("<tr id='tr'></tr>")

$("#sijitable").append($tr)//问题这里吧

var $td=$("<td>list5</td>")

$("#tr").append($td)

}

</script>

</head>

<body onLoad="onload()">

<p id="x">你好!</p>

</body>

</html>


欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/bake/11655988.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-17
下一篇2023-05-17

发表评论

登录后才能评论

评论列表(0条)

    保存