• 使用JQuery 做仿asp.net 中的gridview 控件编辑效果


     <script src="jquery-1.3.1.js" type="text/javascript"></script>                                 //*********导入 JQuery
    <script type="text/javascript">
     $(document).ready(function(){
     
       //给class为content添加事件         
      $('.content').bind("click",function(){
        $(this).children('.show').hide();
        $(this).children('.input').show();
        $(this).next().children('input:eq(1)').removeAttr("disabled");
        }); 
        
        //给按两个钮添加事件
      $('.content').next().children().bind("click",function rev(){
           var $a=$(this) ;    
           if($a.val()=="取消")   
           {
              $a.parent().prev().children('.show').show();
              $a.parent().prev().children('.input').hide();
              $a.next().attr("disabled","disabled");
           }
           if($a.val()=="修改")
           {
             alert ($a.parent().prev().children('.input').children('input').val());
             // 是用Ajax 进行交互 提交数据
           }
        }); 
    })
    </script>
    </head>
    <body>
    <table width="418" border="0">
      <tr>
        <td colspan="3" bgcolor="#333333">新闻种类编辑</td>
      </tr>
      <tr>
        <td width="62">编号</td>
        <td width="213" align="center">内容</td>
        <td width="129" align="center">编辑</td>
      </tr>
        <tr>
        <td width="62">1</td>
        <td width="213"  class="content"><div class="show" >军事新闻</div><div class="input" style="display:none;"> <input type="text" value="军事新闻"/></div></td>
        <td width="129" id="edit">
            &nbsp;&nbsp;&nbsp;&nbsp;
            <input id="Button1" type="button" value="取消" /> <input id="Button2" type="button" value="修改" disabled="disabled"/>
        </td>
      </tr>
          <tr>
        <td width="62">2</td>
        <td width="213"  class="content"><div class="show" >国际新闻</div><div class="input" style="display:none;"> <input type="text" value="国际新闻"/></div></td>
        <td width="129" id="Td1">
            &nbsp;&nbsp;&nbsp;&nbsp;
            <input id="Button3" type="button" value="取消" /> <input id="Button4" type="button" value="修改" disabled="disabled"/>
        </td>
      </tr>
            <tr>
        <td width="62">3</td>
        <td width="213"  class="content"><div class="show" >国内新闻</div><div class="input" style="display:none;"> <input type="text" value="国内新闻"/></div></td>
        <td width="129" id="Td2">
            &nbsp;&nbsp;&nbsp;&nbsp;
            <input id="Button5" type="button" value="取消" /> <input id="Button6" type="button" value="修改" disabled="disabled"/>
        </td>
      </tr>
    </table>
    </body>
    </html>
  • 相关阅读:
    设置DataGridView垂直滚动条
    在自定义MessageBox控件里添加键盘回车事件。
    通过访问注册表,表判断系统是否装excel
    让文本框里只能输入数字
    新晋菜鸟的错误
    jdbc连接数据库以及crud(简单易懂,本人亲测可用 有源代码和数据库)
    springboot 错误求解决
    maven 导包报错
    最短路径Dijkstra
    读写者问题
  • 原文地址:https://www.cnblogs.com/voidobject/p/3975510.html
Copyright © 2020-2023  润新知