源码网,源码论坛,源码之家,商业源码,游戏源码下载,discuz插件,棋牌源码下载,精品源码论坛

 找回密码
 立即注册
楼主: ttx9n

[HTML/Xhtml] 点击按钮文字变成input框,点击保存变成文字的实现代码

[复制链接]

7万

主题

861

回帖

32万

积分

论坛元老

Rank: 8Rank: 8

积分
329525
发表于 2016-5-9 17:15:53 | 显示全部楼层 |阅读模式
下面小编就为大家带来一篇点击按钮文字变成input框,点击保存变成文字的实现代码。小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

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

XML/HTML Code复制内容到剪贴板
  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

回复

使用道具 举报

1

主题

2万

回帖

176

积分

注册会员

Rank: 2

积分
176
发表于 2022-9-2 21:54:29 | 显示全部楼层
论坛有你更精彩!
回复 支持 反对

使用道具 举报

1

主题

2万

回帖

93

积分

注册会员

Rank: 2

积分
93
发表于 2022-10-4 15:03:25 | 显示全部楼层
啪啪啪生怕PSP怕
回复 支持 反对

使用道具 举报

0

主题

2万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2023-5-18 12:34:44 | 显示全部楼层
不错的源码论坛
回复 支持 反对

使用道具 举报

0

主题

2万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2023-6-16 23:04:53 | 显示全部楼层
我找了挺久终于找到了
回复 支持 反对

使用道具 举报

1

主题

2万

回帖

307

积分

中级会员

Rank: 3Rank: 3

积分
307
发表于 2024-2-21 04:11:50 | 显示全部楼层
dfdsafdsfdsfdsf
回复 支持 反对

使用道具 举报

2

主题

2万

回帖

67

积分

注册会员

Rank: 2

积分
67
发表于 2024-5-6 01:01:55 | 显示全部楼层
有什么好的服务器
回复 支持 反对

使用道具 举报

4

主题

2万

回帖

58

积分

注册会员

Rank: 2

积分
58
发表于 2024-5-13 13:18:59 | 显示全部楼层
这个源码还可以
回复 支持 反对

使用道具 举报

1

主题

2万

回帖

176

积分

注册会员

Rank: 2

积分
176
发表于 2024-5-23 14:18:01 | 显示全部楼层
而快乐你们快乐马年快乐
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

68

积分

注册会员

Rank: 2

积分
68
发表于 2024-6-30 16:09:41 | 显示全部楼层
谢谢您的分享!
回复 支持 反对

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

手机版|小黑屋|网站地图|源码论坛 ( 海外版 )

GMT+8, 2025-2-2 19:54 , Processed in 0.075113 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表