国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > JS > 正文

tbody元素支持嵌套的注意方法

2024-09-06 12:42:53
字體:
來源:轉載
供稿:網友
function addMessage(messageID,userName,userCreateDate,articleCount,subject,body,creationDate,modifiedDate) 

var br; 
var row = document.createElement("tr"); 
var cell = document.createElement("td"); 

var cellTr = document.createElement("tr"); 
var cellTd = document.createElement("td"); 
cellTd.appendChild(document.createTextNode("用戶名:"+userName)); 
cellTr.appendChild(cellTd); 
cell.appendChild(cellTr); 
cellTd = document.createElement("td"); 
cellTd.appendChild(document.createTextNode("創建時間:+userCreateDate")); 
cellTr.appendChild(cellTd); 
cell.appendChild(cellTr); 
cellTd = document.createElement("td"); 
cellTd.appendChild(document.createTextNode("發表文章:"+articleCount)); 
cellTr.appendChild(cellTd); 
cell.appendChild(cellTr); 
row.appendChild(cell); 

cell = document.createElement("td"); 
cellTr = document.createElement("tr"); 
cellTd = document.createElement("td"); 
cellTd.appendChild(document.createTextNode("發表時間:"+creationDate+" "+"修改時間:"+modifiedDate)); 
cellTr.appendChild(cellTd); 
cell.appendChild(cellTr); 
cellTr = document.createElement("tr"); 
cellTd = document.createElement("td"); 
cellTd.appendChild(document.createTextNode(subject)); 
br = document.createElement("br"); 
cellTd.appendChild(br); 
cellTd.appendChild(document.createTextNode(body)); 
cellTr.appendChild(cellTd); 
cell.appendChild(cellTr); 
row.appendChild(cell); 

document.getElementById("messageList").appendChild(row); 

以上代碼在ie中出現"意外的調用了方法或屬性訪問",錯誤指向最后一句.望各大俠指點迷津

評價:  
你這段代碼感覺不優雅~沒有重用性~性能底~、  
建議:  
1>采用函數封裝實現重用。  
2>對于table的內部嵌套采用如下格式:  


<table>   
<tbody>   
<tr>   
<td></td>   
...    
</tr>   
...    
</tbody>   
<tbody>   
</tbody>   
...    
</table>   


對table動態生成,采用從內到外添加的方案。另盡可能少使用document.createTextNode,性能低。  
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南京市| 阿鲁科尔沁旗| 平舆县| 扎囊县| 娄底市| 郎溪县| 天门市| 蓬莱市| 颍上县| 镇赉县| 南江县| 淅川县| 峨边| 苍溪县| 辽中县| 普安县| 中阳县| 德安县| 田东县| 沽源县| 县级市| 岐山县| 于田县| 民丰县| 三原县| 怀集县| 漯河市| 乌兰察布市| 扎鲁特旗| 喀喇| 横峰县| 通江县| 大洼县| 荣昌县| 辽源市| 连平县| 江西省| 阳谷县| 张家界市| 八宿县| 雷州市|