zoukankan      html  css  js  c++  java
  • jquery如何在对表格添加删除后再对其前面加上顺序的序列号

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>无标题页</title>
     <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
            function del(obj){
                $(obj).parents("tr").siblings().each(function(i){
                    $(this).find("td").eq(0).html(i+1)
                })
                $(obj).parents("tr").remove();
            }
        </script>
    </head>
    <body>
    <table>
        <tr><td>1</td><td>a</td><td><a onclick="del(this)">删除</a></td></tr>
        <tr><td>2</td><td>b</td><td><a onclick="del(this)">删除</a></td></tr>
        <tr><td>3</td><td>c</td><td><a onclick="del(this)">删除</a></td></tr>
        <tr><td>4</td><td>d</td><td><a onclick="del(this)">删除</a></td></tr>
     <tr><td>5</td><td>a</td><td><a onclick="del(this)">删除</a></td></tr>
        <tr><td>6</td><td>b</td><td><a onclick="del(this)">删除</a></td></tr>
        <tr><td>7</td><td>c</td><td><a onclick="del(this)">删除</a></td></tr>
        <tr><td>8</td><td>d</td><td><a onclick="del(this)">删除</a></td></tr>
     
    </table>
    </body>
    </html>
    <script type="text/javascript">
    /**遍历添加动态也可以*/
            /*$('table a').each(function(){
      
         $(this).click(function(){
        
        
           $(this).parents("tr").siblings().each(function(i){
       
                    $(this).find("td").eq(0).html(i+1)
                })
                $(this).parents("tr").remove();
       
       
          })
      
      })*/
    </script>

  • 相关阅读:
    MyEclipse_安装和破解
    Gparted for partition of Linux on graphic interface
    hadoop native lib can't load use local lib
    oracle java for ubuntu apt-get
    vi set the tab width for python
    sqlite3 on python for newbies
    python multiprocessing pool
    HRESULT: 0x80040228
    获取鼠标坐标
    Oracle 与 ODAC 一起安装
  • 原文地址:https://www.cnblogs.com/dearxinli/p/3031351.html
Copyright © 2011-2022 走看看