日期:2014-05-16 浏览次数:20330 次
var name=$("name").value; var salary=$("salary").value;
------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <style> table{ font-size:24px; font-style:italic; } .s1{ background-color:#ff99ee; } </style> <script src="prototype-1.6.0.3.js"></script> <script> /*dom方式*/ function addRow(){ var name=$f("name"); var salary=$f("salary"); var td1=document.createElement("td"); var td2=document.createElement("td"); td1.innerHTML=name; td2.innerHTML=salary; var tr1=document.createElement("tr"); tr1.appendChild(td1); tr1.appendChild(td2); [color=#FF0000]$("tb").append(tr1);[/color]//jquery 中是用append方法,JS中才用appendChild } </script> </head> <body style="font-size:30px;"> <table width="60%" border="1" cellpadding="0" cellspacing="0" id="tb"> <tr> <td>姓名<br></td> <td>薪水 <br></td></tr> <tr> <td>zs<br></td> <td>2000 <br></td></tr> <tr> <td>ww <br></td> <td>3000 <br></td></tr> </table> 姓名:<input name="name" id="name"/>薪水:<input name="salary" id="salary"/><input type="button" value="添加" onclick="addRow();"> </body> </html>
------解决方案--------------------
function addRow(){ //获取值 var name=$