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>

  • 相关阅读:
    postgresql postgres.Jsonb
    gorm jsonb
    json
    postgresql重置序列和自增主键
    go build x509: certificate has expired or is not yet valid
    权限修饰符
    交换两个变量的值
    Java编译报错:编码GBK的不可映射字符
    原码反码补码的理解
    Scanner类中hasNext()方法的解析
  • 原文地址:https://www.cnblogs.com/dearxinli/p/3031351.html
Copyright © 2011-2022 走看看