zoukankan      html  css  js  c++  java
  • jq 表格添加删除行


    直接可以使用::::::::::::::::::::::::::::::
    <script type="text/javascript">
    var rowCount=0; //行数默认1行
    //添加行
    function addRow(){
    rowCount++;
    var newRow=' <tr id="option"'+rowCount+' class="q'+rowCount+'"><td> <a class="sc" href="#">上传图片</a> </td> <td> <select> <option>管桩</option> </select> </td> <td> <input type="text" value="水溶性涂料" title="水溶性涂料" /> </td> <td> <input type="text" value="涂料" title="涂料" /> </td> <td> <input type="text" value="50kg/袋" title="50kg/袋" /> </td> <td> <input type="text" value="红黑" title="红黑" /> </td> <td> <input type="text" value="巴斯夫" title="巴斯夫" /> </td> <td> <input type="text" value="广州" title="广州" /> </td> <td> <input type="text" value="kg" title="kg" /> </td> <td> <input type="text" value="1800" title="1800" /> </td> <td> <input type="text" value="5000" title="5000" /> </td> <td> <a id="q'+rowCount+'" onclick="delRow(this)">删除</a> </td> </tr>';
    $('#optionContainer').append(newRow);
    //alert('哈哈');
    }

    //删除行
    function delRow(rowIndex){
    alert(rowIndex.id);
    $('.'+rowIndex.id).remove();
    }
    </script>
  • 相关阅读:
    [LeetCode] 617. Merge Two Binary Trees
    [LeetCode] 738. Monotone Increasing Digits
    289. Game of Life
    305. Number of Islands II
    288. Unique Word Abbreviation
    271. Encode and Decode Strings
    393. UTF-8 Validation
    317. Shortest Distance from All Buildings
    286. Walls and Gates
    296. Best Meeting Point
  • 原文地址:https://www.cnblogs.com/qjyking/p/5461125.html
Copyright © 2011-2022 走看看