首页前端开发HTML点击按钮文字变成input框,点击保存变成文字的实现代码

点击按钮文字变成input框,点击保存变成文字的实现代码

时间2024-01-27 13:30:03发布访客分类HTML浏览575
导读:收集整理的这篇文章主要介绍了点击按钮文字变成input框,点击保存变成文字的实现代码,觉得挺不错的,现在分享给大家,也给大家做个参考。 点击按钮文字变成input框,点击保存变成文字的实现代码XML/HTML Code@H_512...
收集整理的这篇文章主要介绍了点击按钮文字变成input框,点击保存变成文字的实现代码,觉得挺不错的,现在分享给大家,也给大家做个参考。

点击按钮文字变成input框,点击保存变成文字的实现代码

XML/HTML Code@H_512_9@复制内容到剪贴板
  1. !DOCTYPE html>   
  2. html lang="en">   
  3. head>   
  4.   meta http-equiv="Content-type" content="text/html;  charset=utf-8" />   
  5.   meta charset="utf-8">   
  6.   tITle> 点击按钮文字变成input框,点击保存变成文字/title>   
  7.   style type="text/css">   
  8.   table{  text-align: center;  font-Size: 14px; }   
  9.   table> thead> tr> th{  font-weight: normal; }   
  10.   .text-right{  padding-right:73px;  text-align: right; }   
  11.   .text{  width: 50px;  height: 30px;  border: 1px solid #ddd;  text-align: center; }   
  12.   /style>   
  13.   script type="text/javascript" src="js/jquery.min.js"> /script>   
  14. /head>   
  15.   
  16. body>   
  17.   table>   
  18.     thead>   
  19.       tr>   
  20.         th width="400"> 品名/th>   
  21.         th width="200"> 件数/th>   
  22.       /tr>   
  23.     /thead>   
  24.     tbody>   
  25.       tr height="50">   
  26.         td> iphone6s/td>   
  27.         td class="edit"> 2/td>   
  28.       /tr>   
  29.       tr height="50">   
  30.         td> 小米5/td>   
  31.         td class="edit"> 5/td>   
  32.       /tr>   
  33.     /tbody>   
  34.     tfoot>   
  35.       tr>   
  36.         td colspan="2" class="text-right">   
  37.           button type="button" class="BTn" onclick="change(this)"> 修改/button>   
  38.         /td>   
  39.       /tr>   
  40.     /tfoot>   
  41.   /table>   
  42.   
  43. script type="text/javascript">   
  44. function change(obj){   
  45.   VAR xg=$(obj).html();   
  46.   if(xg=='修改'){   
  47.     $('.edit').each(function(){   
  48.       var old=$(this).html();   
  49.       $(this).html("input type='text' name='editname' class='text' value="+old+" > ");   
  50.     } )   
  51.     $(obj).html('保存');   
  52.   } else if(xg=='保存'){   
  53.     $('input[name=editname]').each(function(){   
  54.       var old=$(this).html();   
  55.       var newfont=$(this).parent('td').parent('tr').children().find('input').val();   
  56.       $(this).parent('td').html(newfont);   
  57.     } )   
  58.     $(obj).html('修改');   
  59.   }   
  60. }   
  61. /script>   
  62.   
  63.   
  64.   
  65. /body>   
  66. /html>   

以上这篇点击按钮文字变成input框,点击保存变成文字的实现代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

原文地址:http://www.cnblogs.com/yuxiaoqi912/p/5470354.html

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!

按钮文字

若转载请注明出处: 点击按钮文字变成input框,点击保存变成文字的实现代码
本文地址: https://pptw.com/jishu/588262.html
html的footer置于页面最底部的简单实现方法 关于table表格中的内容溢出布局方法

游客 回复需填写必要信息