點擊按鈕文字變成input框,點擊保存變成文字的實現(xiàn)代碼
發(fā)布時間:2016-05-09 17:15:53 作者:佚名
我要評論

下面小編就為大家?guī)硪黄c擊按鈕文字變成input框,點擊保存變成文字的實現(xiàn)代碼。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
點擊按鈕文字變成input框,點擊保存變成文字的實現(xiàn)代碼
XML/HTML Code復(fù)制內(nèi)容到剪貼板
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta charset="utf-8">
- <title>點擊按鈕文字變成input框,點擊保存變成文字</title>
- <style type="text/css">
- table{ text-align: center; font-size: 14px;}
- table>thead>tr>th{ font-weight: normal;}
- .text-right{ padding-right:73px; text-align: right;}
- .text{ width: 50px; height: 30px; border: 1px solid #ddd; text-align: center;}
- </style>
- <script type="text/javascript" src="js/jquery.min.js"></script>
- </head>
- <body>
- <table>
- <thead>
- <tr>
- <th width="400">品名</th>
- <th width="200">件數(shù)</th>
- </tr>
- </thead>
- <tbody>
- <tr height="50">
- <td>iPhone6s</td>
- <td class="edit">2</td>
- </tr>
- <tr height="50">
- <td>小米5</td>
- <td class="edit">5</td>
- </tr>
- </tbody>
- <tfoot>
- <tr>
- <td colspan="2" class="text-right">
- <button type="button" class="btn" onclick="change(this)">修改</button>
- </td>
- </tr>
- </tfoot>
- </table>
- <script type="text/javascript">
- function change(obj){
- var xg=$(obj).html();
- if(xg=='修改'){
- $('.edit').each(function(){
- var old=$(this).html();
- $(this).html("<input type='text' name='editname' class='text' value="+old+" >");
- })
- $(obj).html('保存');
- }else if(xg=='保存'){
- $('input[name=editname]').each(function(){
- var old=$(this).html();
- var newfont=$(this).parent('td').parent('tr').children().find('input').val();
- $(this).parent('td').html(newfont);
- })
- $(obj).html('修改');
- }
- }
- </script>
- </body>
- </html>
以上這篇點擊按鈕文字變成input框,點擊保存變成文字的實現(xiàn)代碼就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
原文地址:http://www.cnblogs.com/yuxiaoqi912/p/5470354.html
相關(guān)文章
限制html文本框input只能輸入數(shù)字和小數(shù)點
本文主要介紹了限制html文本框input只能輸入數(shù)字和小數(shù)點的方法。具有很好的參考價值。下面跟著小編一起來看下吧2017-03-27input checkbox 擴(kuò)大點擊范圍的實現(xiàn)方法
下面小編就為大家?guī)硪黄猧nput checkbox 擴(kuò)大點擊范圍的實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-07-23- 下面小編就為大家?guī)硪黄P(guān)于input的file 控件及美化。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-07-01
淺談html中input只讀屬性readonly和disable的區(qū)別
下面小編就為大家?guī)硪黄獪\談html中input只讀屬性readonly和disable的區(qū)別。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-06-14快速解決input[type=file]打開時慢、卡頓的問題
下面小編就為大家?guī)硪黄旅嫘【幘蜑榇蠹規(guī)硪黄焖俳鉀Qinput[type=file]打開時慢、卡頓的問題。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編2017-08-11