JavaScript ±í¸ñ¶ÔÏóºÍ²Ù×÷
Ò»¡£È¡±í¸ñ¶ÔÏó
var getTable= document.getElementById("tabHeTong");
¶þ¡£²åÈëÐÐ
var oTR = getTable.insertRow();//ÐÂÔöÒ»ÐÐ
Èý¡£Ä³ÐмÓÈëÁÐ
var oTDa = oTR.insertCell();//ÐÂÔöÒ»ÁÐ
var oTDb = oTR.insertCell();//ÐÂÔö¶þÁÐ
var oTDc = oTR.insertCell();//ÐÂÔöÈýÁÐ
ËÄ¡£É¾³ýÐУº
getTable.deleteRow(flagRow-1);//ɾ³ýÐÐ
Î塣ѡÖÐÐУº
var i=event.srcElement.parentNode.parentNode.rowIndex;
Áù¡£Ê¾Àý£º È¡±í¸ñµ±Ç°ÐÐÊý¾Ý
var currRowIndex=event.srcElement.parentNode.parentNode.rowIndex;
var objTable= document.getElementById("contable");
var row=objTable.rows[currRowIndex];
for(var i=1;i<row.cells.length;i++){
alert(objTable.rows[currRowIndex].cells[i].innerText);
}
Table±í¸ñ¶ÔÏó
Table¶ÔÏó:±íʾHTMLÎĵµÖÐµÄ±í£¬¶ÔÓÚÎĵµÖÐÿ¸ö<table>±ê¼Ç£¬ä¯ÀÀÆ÷¶¼´´½¨Ò»¸öTable¶ÔÏó.
Table¶ÔÏ󼯺Ï
¼¯ºÏ
ÃèÊö
cells[]
»ñÈ¡°üº¬±í¸ñÖÐËùÓе¥Ôª¸ñµÄÊý×é
rows[]
»ñÈ¡°üº¬±í¸ñÖÐËùÓÐÐеÄÊý×é
tBodies[]
»ñÈ¡°üº¬±í¸ñÖÐËùÓÐtbodyµÄÊý×é
Table¶ÔÏóÊôÐÔ
border
ÉèÖûò»ñÈ¡±í¸ñ±ß¿ò
caption
ÉèÖûò»ñÈ¡±í¸ñ±êÌâ
cellPadding
ÉèÖûò»ñȡÿ¸öµ¥Ôª¸ñ±ß¿òÓëÄÚÈݵĿí¶È
cellSpacing
ÉèÖûò»ñÈ¡±í¸ñÖе¥Ôª¸ñµÄ¼ä¾à
frame
ÉèÖûò»ñÈ¡±í¸ñ¾ßÓÐÄÄЩ±ß¿ò
rules
ÉèÖûò»ñÈ¡±í¸ñÖеÄÄÚ²¿±ß¿ò
summary
ÉèÖûò»ñÈ¡±í¸ñµÄÃèÊö
tFoot
»ñÈ¡±í¸ñµÄtFoot¶ÔÏó
tHead
»ñÈ¡±í¸ñµÄtHead¶ÔÏó
width
ÉèÖûò»ñÈ¡±í¸ñ¿í¶È
Table¶ÔÏó·½·¨
createCaption()
Ϊ±í¸ñ´´½¨Ò»¸ö¿ÕµÄ±êÌâÔªËØ
createTFoot()
Ϊ±í¸ñ´´½¨Ò»¸ö¿ÕµÄtFootÔªËØ
createTHead()
Ϊ±í¸ñ´´½¨Ò»¸ö¿ÕµÄtHeadÔªËØ
deleteCaption()
ɾ³ý±í¸ñµÄ±êÌâÔªËØ
deleteRow()
ɾ³ýÖ¸¶¨µÄ±í¸ñÐÐ
deleteTFoot()
ɾ³ý±í¸ñµÄtFootÔªËØ
deleteTHead()
ɾ³ý±í¸ñµÄtHeadÔªËØ
insertRow()
Ïò±í¸ñÖвåÈëÐÂÐÐ
TableCell¶ÔÏó:±íʾHTMLÎĵµÖбíµÄµ¥Ôª¸ñ£¬¶ÔÓÚÎĵµÖÐÿ¸ö<td>±ê¼Ç£¬ä¯ÀÀÆ÷¶¼´´½¨Ò»¸öTableCell¶ÔÏó.
TableCell¶ÔÏóÊôÐÔ
ÊôÐÔ
ÃèÊö
abbr
ÉèÖûò»ñÈ¡µ¥Ôª¸ñµÄÕªÒª
align
ÉèÖûò»ñÈ¡µ¥Ôª¸ñÖÐÎÄ×ÖµÄˮƽ¶ÔÆë·½Ïò
axis
ÉèÖûò»ñÈ¡ÒÔ¶ººÅ·Ö¸ôµÄÏà¹Øµ¥Ôª¸ñ×
Ïà¹ØÎĵµ£º
ÐÞ¸ÄÑ»·µÄÖ´Ðз½Ê½
for(var i=0;i<element.childNodes.length;i++){
Ö´ÐдúÂë
}
ÕâÖÖ·½Ê½Ã¿´ÎÑ»·¶¼ÒªÈ¡element.childNodes.lengthµÄÖµ£¬Ó¦¸Ã¸ÄΪÈçϵÄ
var n£½element.childNodes.length
for(var i=0;i<n;i++){
Ö´ÐдúÂë
}
2£ºÐÞ¸Ädom²Ù×÷µÄ´ÎÊý
domÅúÁ¿²åÈëÒ»ÅúÀàËƵĽڵ㲻ÈçÏȹ¹ÔìÒ»¸ö¶ÔÏó£¬ ......
ÔÚÉÏ´«²Ù×÷ÖУ¬¾³£»áÓöµ½ÒªÇóÖ¸¶¨ÉÏ´«ÎļþµÄ¸ñʽ£¬ÏÂÃæµÄʵÀýÊÇÔÚ¿Í»§¶Ëͨ¹ýJavaScriptÑéÖ¤ÉÏ´«Í¼Æ¬¸ñʽΪjpg/gif/png
<html>
<head>
<mce:script language="JavaScript" type="text/JavaScript"><!--
var img=null;
function checkPic(picForm){
var location=picForm.pic.v ......
ɾ³ýÐÐ
<script>
function del(obj)
{
obj.parentNode.parentNode.removeNode(true);
}
</script>
<body& ......
ÔÎÄ£º¡¶Speeding up JavaScript: Working with the DOM¡·
×÷Õߣº KeeKim Heng, Google Web Developer
ÔÚÎÒÃÇ¿ª·¢»¥ÁªÍø¸»Ó¦Óã¨RIA£©Ê±£¬ÎÒÃǾ³£Ð´Ò»Ð©javascript½Å±¾À´Ð޸ĻòÕßÔö¼ÓÒ³ÃæÔªËØ£¬ÕâЩ¹¤×÷×îÖÕÊÇDOM——»òÕß˵Îĵµ¶ÔÏóÄ£ÐÍ——À´Íê³ÉµÄ£¬¶øÎÒÃǵÄʵÏÖ·½Ê½»áÓ°Ïìµ½Ó¦ÓõÄÏìÓ¦Ëٶȡ£
DO ......