Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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¶ÔÏóµÄ·Ï³ý


ECMAScriptÓÐÎÞÓô洢µ¥ÔªÊÕ¼¯³ÌÐò£¬µ±ÔÚÔÙûÓжԶÔÏóµÄÒýÓÃʱ£¬³Æ¸Ã¶ÔÏ󱻷ϳý£¨dereference£©ÁË¡£
ÔËÐÐÎÞÓô洢µ¥ÔªÊÕ¼¯³ÌÐòʱ£¬ËùÓзϳýµÄ¶ÔÏ󶼱»Ïú»Ù¡£
°Ñ¶ÔÏóµÄËùÓÐÒýÓö¼ÉèÖÃΪnull£¬¿ÉÒÔÇ¿ÖÆÐԵķϳý¶ÔÏó£¬ÀýÈ磺
    var oObject = new Object;
    .......
   &n ......

javaScript(&jQuery)¹¤¾ß¼°ÏàÓ¦ÍøÕ¾×ÊÁÏ

1.Dean Edwards±àдµÄPacker£¨http://dean.edwards.name/packer/£©£¬ÓÃÓÚѹËõJavaScript
2.»ñÈ¡JQuery£ºhttp:/jquery.com 
                     http://docs.jquery.com/Downloading_jQuery   ÏÂÔظ÷¸ö°æ±¾¼°ÏàÓ¦°ïÖúÎ ......

JavaScriptµÄÔËËã·û


deleteÖ»ÄÜɾ³ý¿ª·¢Õ߶¨ÒåµÄÊôÐÔ»ò·½·¨£¬Ô­Ê¼µÄECMAScript·½·¨²»ÄÜɾ³ý£¬ÒòΪ²»ÊÇ¿ª·¢Õ߶¨ÒåµÄ£¬±ÈÈ磺toString()¡£
        var o = new Object;
        o.name = "Nicholas";
        delete o.name;
   &n ......

50¸öʵÓõÄJavaScript¹¤¾ß JavaEye¼¼ÊõÍøÕ¾

50¸öʵÓõÄJavaScript¹¤¾ß- - JavaEye¼¼ÊõÍøÕ¾
JavaScriptÊÇÒ»¸ö¹¦ÄÜÇ¿´óµÄ¿Í»§¶Ë½Å±¾ÓïÑÔ£¬Ðí¶àÏÖ´ú»¯µÄÍøÕ¾ºÍWebÓ¦ÓóÌÐò¶¼»áʹÓõ½Ëü¡£JavaScript¿ÉÒÔÔöÇ¿Óû§µÄÌåÑ飬²¢Ìṩ·á¸»µÄ»¥¶¯Ê½×é¼þºÍ¹¦ÄÜ¡£ËäÈ»ËüµÄÓï·¨Ï൱¼òµ¥£¬µ«ÊǶԿª·¢ÕßÀ´Ëµ»¹ÊǺÜÓÐÄѶȵģ¬ÒòΪËüÒªÔËÐÐÔÚWebä¯ÀÀÆ÷ÖС£
¡¡¡¡ÒÔÏÂÊÇÎÒÃÇΪÄãÍƼöµÄ50¸ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ