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 ZSH terminal in CentOS 7.x

1. Install basic components First, execute the yu...

Code analysis of user variables in mysql query statements

In the previous article, we introduced the MySQL ...

CSS performance optimization - detailed explanation of will-change usage

will-change tells the browser what changes will h...

Graphic tutorial on installing Ubuntu 18.04 on VMware 15 virtual machine

In the past few years, I have been moving back an...

HTML5+CSS3 coding standards

The Golden Rule No matter how many people are wor...

How to use a field in one table to update a field in another table in MySQL

1. Modify 1 column update student s, city c set s...

Solution to span width not being determined in Firefox or IE

Copy code The code is as follows: <html xmlns=...

TinyEditor is a simple and easy-to-use HTML WYSIWYG editor

A few days ago, I introduced to you a domestic xh...

MySql8 WITH RECURSIVE recursive query parent-child collection method

background When developing a feature similar to c...

Detailed explanation of common MySQL operation commands in Linux terminal

Serve: # chkconfig --list List all system service...

33 of the best free English fonts shared

ChunkFive Free Typefamily Cuprum JAH I Free font Y...

An article to help you understand Js inheritance and prototype chain

Table of contents Inheritance and prototype chain...

Native JS implements a very good-looking counter

Today I will share with you a good-looking counte...