jsÔõôɾ³ý±í¸ñµÄijһÐÐ
ҪʹÓà javascript ɾ³ý±í¸ñÖеÄÐУ¬¿ÉÒÔ£º»ñȡҪɾ³ýÐеÄË÷Òý¡£Ê¹Óà deleterow() ÒªÁìɾ³ýÐУ¬´«ÈëҪɾ³ýÐеÄË÷Òý×÷Ϊ²ÎÊý¡£
ÔõÑùʹÓà JavaScript ɾ³ý±í¸ñÖеÄÐÐ
ҪʹÓà JavaScript ɾ³ý±í¸ñÖеÄÐУ¬¿ÉÒÔʹÓà deleteRow() ÒªÁì¡£Õâ¸öÒªÁì¿ÉÒÔɾ³ýÖ¸¶¨µÄÐС£ÒÔÏÂÊÇÔõÑùʵÏֵİ취£º
»ñȡҪɾ³ýÐеÄË÷Òý£º
ʹÓà rowIndex ÊôÐÔ»ñȡҪɾ³ýÐеÄË÷Òý¡£
const rowIndex = row.rowIndex;
µÇ¼ºó¸´ÖÆ
ʹÓà deleteRow() ÒªÁìɾ³ýÐУº
ʹÓà deleteRow() ÒªÁìɾ³ýÐУ¬´«ÈëҪɾ³ýÐеÄË÷Òý×÷Ϊ²ÎÊý¡£
table.deleteRow(rowIndex);
µÇ¼ºó¸´ÖÆ
ʾÀý´úÂ룺
ÒÔÏÂÊÇÒ»¸öʾÀý´úÂ룬չʾÁËÔõÑùʹÓà JavaScript ɾ³ý±í¸ñÖеÄÐУº
µÇ¼ºó¸´ÖÆ
ÐÕÃû | ÄêËê | ¶¼»á |
---|---|---|
Ô¼º² | 30 | ŦԼ |
ÂêÀö | 25 | ÂåÉ¼í¶ |
´÷·ò | 40 | ¾É½ðɽ |
ɾ³ýµÚÈýÐÐ <script> function deleteRow() { const row = document.getElementById(“row-3”); const rowIndex = row.rowIndex; const table = row.parentElement; table.deleteRow(rowIndex); } </script>
µ¥»÷°´Å¥½«É¾³ý±í¸ñÖеĵÚÈýÐС£
ÒÔÉϾÍÊÇjsÔõôɾ³ý±í¸ñµÄijһÐеÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡