Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javascript ¶¯Ì¬´´½¨±í¸ñ

ÀûÓÃjsÀ´¶¯Ì¬´´½¨±í¸ñÓÐÁ½ÖÖ¸ñʽ£¬appendChild()ºÍinsertRow¡¢insertCell()¡£Á½ÖÖ·½Ê½Æäʵ²î²»¶à£¬µ«µÚÒ»ÖÖÓпÉÄÜÔÚIEÉÏÓÐÎÊÌ⣬ËùÒÔÍƼö´ó¼ÒʹÓõڶþÖÖÁË£¬Ö±½Ó˵°É¡£
1¡¢inserRow()ºÍinsertCell()º¯Êý
insertRow()º¯Êý¿ÉÒÔ´ø²ÎÊý£¬ÐÎʽÈçÏ£º
insertRow(index)£ºindex´Ó0¿ªÊ¼
Õâ¸öº¯Êý½«ÐÂÐÐÌí¼Óµ½indexµÄÄÇÒ»ÐÐÇ°£¬±ÈÈçinsertRow(0),Êǽ«ÐÂÐÐÌí¼Óµ½µÚÒ»ÐÐ֮ǰ¡£Ä¬ÈϵÄinsertRow()º¯ÊýÏ൱ÓÚinsertRow(-1)£¬½«ÐÂÐÐÌí¼Óµ½±íµÄ×îºó¡£Ò»°ãÎÒÃÇÔÚʹÓõÄʱºò¶¼ÊÇ£ºobjTable.insertRow(objTable.rows.length).¾ÍÊÇΪ±í¸ñobjTableÔÚ×îºóÐÂÔöÒ»ÐС£
insertCell()ºÍinsertRowµÄÓ÷¨Ïàͬ£¬ÕâÀï¾Í²»ÔÙ˵ÁË¡£
2¡¢deleteRow()ºÍdeleteCell()·½·¨
deleteRow()º¯Êý¿ÉÒÔ´ø²ÎÊý£¬ÐÎʽÈçÏ£ºdeleteRow(index)£ºindex´Ó0¿ªÊ¼
ºÍÉÏÃæÁ½¸ö·½·¨²î²»¶àµÄÒâ˼£¬¾ÍÊÇɾ³ýÖ¸¶¨Î»ÖõÄÐк͵¥Ôª¸ñ¡£Òª´«ÈëµÄ²ÎÊý£ºIndexÊÇÐÐÔÚ±í¸ñÖеÄλÖ㬿ÉÒÔÏÂÃæµÄ·½·¨È¡µÃÈ»ºóȥɾ³ý£º
var row=document.getElementById("ÐеÄId");
var index=row.rowIndex;//ÓÐÕâ¸öÊôÐÔ£¬ºÙºÙ
objTable.deleteRow(index);
ÔÚʹÓùý³ÌÖÐÎÒÅöµ½µÄÒ»¸öÎÊÌâ¸ú´ó¼Ò˵һÏ£¬¾ÍÊÇɾ³ý±í¸ñµÄÐеÄʱºò£¬Èç¹ûÄãɾ³ýÁËijһÐУ¬ÄÇô±í¸ñÐÐÊýÊÇÂíÉϾͱ仯µÄ£¬ËùÒÔÈç¹ûÄãҪɾ³ý±í¸ñµÄËùÓÐÐУ¬ÏÂÃæµÄ´úÂëÊÇ´íÎóµÄ£º
function clearRow(){
   objTable= document.getElementById("myTable");
     
   for( var i=1; i<objTable.rows.length ; i++ )
   {
   tblObj.deleteRow(i);   
      }
}
Õâ¶Î´úÂëҪɾ³ýÔ­À´µÄ±í¸ñµÄ±íÌ壬ÓÐÁ½¸öÎÊÌâ¡£Ê×ÏȲ»ÄÜÊÇdeleteRow(i)£¬Ó¦¸ÃÊÇdeleteRow(1)¡£ÒòΪÔÚɾ³ý±í¸ñÐеÄʱºò£¬±í¸ñµÄÐÐÊýÔڱ仯£¬Õâ¾ÍÊÇÎÊÌâµÄ¹Ø¼ü£¬rows.length×ÜÊÇÔÚ±äС£¬É¾³ýµÄÐÐÊý×ÜÊÇ»á±ÈÔ¤ÏëµÄÒªÉÙÒ»°ë£¬ËùÒÔÕýÈ·µÄɾ³ý±í¸ñµÄÐеĴúÂëÓ¦¸ÃÕâÑù£º
function clearRow(){
   objTable= document.getElementById("myTable");
   var length= objTable.rows.length ;
   for( var i=1; i<length; i++ )
   {
       objTable.deleteRow(i);   
      }
}
3¡¢¶¯Ì¬ÉèÖõ¥Ôª¸ñÓëÐеÄÊôÐÔ
A¡¢²ÉÓÃsetAttribute()·½·¨£¬¸


Ïà¹ØÎĵµ£º

JavaScriptÉèÖôúÂëÑÓʱִÐÐ

//ÈÃij¶Î´úÂëÑÓʱִÐÐ
function delayRun(code, time) {
        var t = setTimeout(code, time);
}
Ó¦ÓþÙÀý£º
<input type="button" name="query" value="ͳ¼Æ" class="long_button" onClick="return delayRun('onQuery()', 1000);"> ......

JavaScript¿ØÖÆ°´Å¥µÄÏÔʾºÍÒþ²Ø

<script language="javascript">
//none±íʾ²»ÏÔʾ°´Å¥
document.getElementById("transFund_bttn").style.display = "none";
document.getElementById("transFundGether_bttn").style.display = "none";
document.getElementById("payGether_bttn").style.display = "none";
function query(){
  &n ......

JavascriptÖÐ×î³£ÓõÄ55¸ö¾­µä¼¼ÇÉ

JavascriptÖÐ×î³£ÓõÄ55¸ö¾­µä¼¼ÇÉ
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)> <td>no </table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4 ......

JavaScriptÖÐ×î³£ÓõÄ55Öм¼ÇÉ

1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)> <td>no </table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy="return false;" oncut="re ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ