Double-click Blank or text into the input box to modify the content:
HTML code
<TD class= "center" ondblclick= "Showelement (This, ' intro ')" >{$vo .intro}</td> <td class=
"center" Ondblclick= "Showelement (this, ' address ')" >{$vo .address}</td>
JS Code
Double-click Modify function Showelement (ELEMENT,ABC) {//Console.log (ABC);
var list = ABC;
var me = element;
var oldhtml = element.innerhtml;
var newobj = document.createelement (' input ');
Newobj.type = ' text '///modify the type of the newly created input element.innerhtml = ';//clear the contents of TD to store the newly created input;
$ (newobj). attr ({value:oldhtml}); Element.appendchild (newobj)//Put input into TD/BIND mouse to input object newobj.onblur = function () {//To determine whether the conditions for sending Ajax are met if (this.v
Alue!= oldhtml) {element.innerhtml = This.value;
var value = This.value;
alert (value);
Send AJAX request var id = $ (Me). Parents ('. Gradea '). Find ('. Sid '). html ();
var url = "{: U (' Admin/friend/onclick ')}";
var btn = $ (this);
$.ajax ({url:url, data:{id:id,list:list,value:value}, type: ' Post ', success:function (data) {
Console.log (data);
if (data = = 0) {alert (' modified successfully ')}else{alert (' Modify failed ');
}})}else{element.innerhtml = oldhtml;//put the original content//return false;
}
} Newobj.focus ();
return false; }
The above is a small set to introduce the JS double-click change Input box to modify the content, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!