Home > Web Front-end > JS Tutorial > body text

How to implement the jQuery double-click editing table function

小云云
Release: 2018-01-06 13:03:44
Original
2092 people have browsed it

We all know the double-click function. This article will introduce you to jquery double-click editing form through example code. Friends who need it can refer to it. I hope it can help everyone.

Let me show you the renderings first:

The following is a simple form editing function implemented in a simple way:

Simple HTML code Skip it, the following is the js implementation process

JavaScript:


##

<span style="font-size:18px;">$(".tables").on("dblclick","td",function(){ 
 if($(this).children("input").length>0){ 
  return false; 
 } 
 var tdDom = $(this); 
 //保存初始值 
 var tdPreText = $(this).text(); 
 //给td设置宽度和给input设置宽度并赋值 
 $(this).width(100).html("<input type=&#39;text&#39;>").find("input").width(100).val(tdPreText); 
 //失去焦点的时候重新赋值 
 var inputDom = $(this).find("input"); 
 inputDom.blur(function(){ 
  var newText = $(this).val(); 
  $(this).remove(); 
  tdDom.text(newText); 
 });</span>
Copy after login

Related recommendations:


##jQuery implementation Detailed explanation of editing the table and generating json results

Explanation on how to use jQuery to implement the double-click editing table function

Using Jquery to implement the editable table and use it AJAX submits modified data to the server_jquery

The above is the detailed content of How to implement the jQuery double-click editing table function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template