欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

點擊按鈕文字變成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)容到剪貼板
  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">件數(shù)</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框,點擊保存變成文字的實現(xiàn)代碼就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

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

相關(guān)文章

  • 限制html文本框input只能輸入數(shù)字和小數(shù)點

    本文主要介紹了限制html文本框input只能輸入數(shù)字和小數(shù)點的方法。具有很好的參考價值。下面跟著小編一起來看下吧
    2017-03-27
  • input checkbox 擴(kuò)大點擊范圍的實現(xiàn)方法

    下面小編就為大家?guī)硪黄猧nput checkbox 擴(kuò)大點擊范圍的實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-07-23
  • 關(guān)于input的file 控件及美化

    下面小編就為大家?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

最新評論