Click the button to turn the text into an input box, click Save to turn it into text implementation code

Click the button to turn the text into an input box, click Save to turn it into text implementation code

Click the button to turn the text into an input box, click Save to turn it into text implementation code

XML/HTML CodeCopy content to clipboard
  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 > Click the button to turn the text into an input box, click Save to turn it into text </ 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" > Product Name </ th >   
  21.         < th   width = "200" > Number of items </ th >   
  22.       </ tr >   
  23.     </ thead >   
  24.     < tbody >   
  25.       < tr   height = "50" >   
  26.         < td > iPhone 6s </ td >   
  27.         < td   class = "edit" > 2 </ td >   
  28.       </ tr >   
  29.       < tr   height = "50" >   
  30.         < td > Xiaomi 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)" > Change </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 == 'modify'){
  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('save');
  52. }else if( xg == 'save'){
  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('modify');
  59. }
  60. }
  61. </ script >   
  62.   
  63.   
  64.   
  65. </ body >   
  66. </ html >   

The above implementation code of clicking a button to turn text into an input box and clicking Save to turn it into text is all the content that the editor shares with you. I hope it can give you a reference and I also hope that you will support 123WORDPRESS.COM.

Original URL: http://www.cnblogs.com/yuxiaoqi912/p/5470354.html

<<:  Vue+ECharts realizes the drawing of China map and automatic rotation and highlighting of provinces

>>:  mysql calculation function details

Recommend

Example of using CSS3 to create Pikachu animated wallpaper

text OK, next it’s time to show the renderings. O...

Detailed explanation of mysql partition function and example analysis

First, what is database partitioning? I wrote an ...

Detailed explanation of the flexible use of CSS grid system in projects

Preface CSS grids are usually bundled in various ...

Zabbix3.4 method to monitor mongodb database status

Mongodb has a db.serverStatus() command, which ca...

Detailed explanation of JavaScript error capture

Table of contents 1. Basic usage and logic 2. Fea...

Detailed explanation of the use of mysql explain (analysis index)

EXPLAIN shows how MySQL uses indexes to process s...

Analysis of the process of implementing Nginx+Tomcat cluster under Windwos

Introduction: Nginx (pronounced the same as engin...

DOCTYPE element detailed explanation complete version

1. Overview This article systematically explains ...

How to use vue-bootstrap-datetimepicker date plugin in vue-cli 3

Demand Background Recently, I plan to use Vue and...

Practical record of vue using echarts word cloud chart

echarts word cloud is an extension of echarts htt...

Linux general java program startup script code example

Although the frequency of starting the shell is v...

Tips on HTML formatting and long files for web design

<br />Related articles: 9 practical suggesti...