zoukankan      html  css  js  c++  java
  • 购物车-删除单行商品-HTMLTableElement.deleteRow()

     wta

    问题发源的代码:

    /*删除单行商品*/
    function deleteRow(rowId){
    	var Index=document.getElementById(rowId).rowIndex; //获取当前行的索引号
    	document.getElementById("shopping").deleteRow(Index);
    	document.getElementById("shopping").deleteRow(Index-1);
    	productCount();
    	}

    https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/rowIndex
    https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/rowIndex
     1 <table>
     2     <tr>
     3         <td>w3434</td>
     4         <td>w35566</td>
     5         <td>w65656</td>
     6     </tr>
     7     <tr>
     8         <td>w1ewewe</td>
     9         <td>w1fdgfge</td>
    10         <td>w1sdf</td>
    11     </tr>
    12     <tr>
    13         <td>w2dffdfgfd</td>
    14         <td>w2ffg</td>
    15         <td>w2yc</td>
    16     </tr>
    17     <tr>
    18         <td>w3qwe</td>
    19         <td>w3f</td>
    20         <td>w3gfg</td>
    21     </tr>
    22 </table>
    23 
    24 
    25 <script>
    26     var wrows = document.getElementsByTagName('tr')
    27     for (var w = 0, wlen = wrows.length; w < wlen; w++) {
    28         console.log(wrows[w])
    29         console.log(wrows[w].rowIndex)
    30     }
    31     // document.getElementsByTagName('table').deleteRow(1)
    32     //Uncaught TypeError: document.getElementsByTagName(...).deleteRow is not a function
    33     document.getElementsByTagName('table')[0].deleteRow(1)
    34 
    35 </script>
     1 <table>
     2     <tr>
     3         <td>w3434</td>
     4         <td>w35566</td>
     5         <td>w65656</td>
     6     </tr>
     7     <tr>
     8         <td>w1ewewe</td>
     9         <td>w1fdgfge</td>
    10         <td>w1sdf</td>
    11     </tr>
    12     <tr>
    13         <td>w2dffdfgfd</td>
    14         <td>w2ffg</td>
    15         <td>w2yc</td>
    16     </tr>
    17     <tr>
    18         <td>w3qwe</td>
    19         <td>w3f</td>
    20         <td>w3gfg</td>
    21     </tr>
    22 </table>
    23 <table>
    24     <tr>
    25         <td>wwwwww3434</td>
    26         <td>www35566</td>
    27         <td>www65656</td>
    28     </tr>
    29     <tr>
    30         <td>www1ewwwewwwe</td>
    31         <td>www1fdgfge</td>
    32         <td>www1sdf</td>
    33     </tr>
    34     <tr>
    35         <td>www2dffdfgfd</td>
    36         <td>www2ffg</td>
    37         <td>www2yc</td>
    38     </tr>
    39     <tr>
    40         <td>www3qwwwe</td>
    41         <td>www3f</td>
    42         <td>www3gfg</td>
    43     </tr>
    44 </table>
    45 
    46 
    47 <script>
    48     var wtabs = document.getElementsByTagName('table')
    49     for (var w = 0, wlen = wtabs.length; w < wlen; w++) {
    50         console.log(wtabs[w])
    51         console.log(wtabs[w].tabIndex)//-1
    52     }
    53 
    54 </script>
  • 相关阅读:
    你知道吗,Flutter内置了10多种show
    强大的Flutter App升级功能
    Flutter 日期时间DatePicker控件及国际化
    你知道吗,Flutter内置了10多种Button控件
    Flutter Form表单控件超全总结
    Flutter 裁剪类组件 最全总结
    Flutter 拖拽控件Draggable看这一篇就够了
    Python 浮点数的冷知识
    Python 为了提升性能,竟运用了共享经济
    Python 之父的解析器系列之六:给 PEG 语法添加动作
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6394917.html
Copyright © 2011-2022 走看看