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

How to install pip package in Linux

1. Download the pip installation package accordin...

Detailed explanation of mysql permissions and indexes

mysql permissions and indexes The highest user of...

Optimizing query speed of MySQL with tens of millions of data using indexes

1. The role of index Generally speaking, an index...

Discuss the application of mixin in Vue

Mixins provide a very flexible way to distribute ...

Markup Language - List

Standardized design solutions - markup languages ...

In-depth analysis of the slow query problem of MySQL Sending data

Through an example, I shared with you the solutio...

Detailed explanation of CSS3+JS perfect implementation of magnifying glass mode

About a year ago, I wrote an article: Analysis of...

How to create a table in mysql and add field comments

Directly post code and examples #Write comments w...

Vue implements the frame rate playback of the carousel

This article example shares the specific code of ...

Vue realizes picture switching effect

This article example shares the specific code of ...

How to forget the root password in Mysql8.0.13 under Windows 10 system

1. First stop the mysql service As an administrat...

How to fix the four sides of the table to scroll up, down, left and right

question: When I was doing project statistics rec...

A comprehensive analysis of what Nginx can do

Preface This article only focuses on what Nginx c...

A Deep Understanding of Angle Brackets in Bash (For Beginners)

Preface Bash has many important built-in commands...