// JavaScript Document $(function(){ $("tr :even").css("background-color","#ffff99"); $("tr td:not(.id)").click(function(){ if($(this ).children('input').length > 0) return; //Get the original content in the table var data=$(this).text(); // Set the content to empty $(this).html(''); var td=$(this); //Create a table var inp=$(''); inp.val(data); inp.css("background-color",$(this).css("background-color")); inp.css("border-width","0px"); inp.css("width",$(this).css("width")); //Put one in the table input form inp.appendTo($(this)); //The focus event is triggered after the form is placed in the table inp.trigger('focus'); //Select all content inp.trigger('select'); //Add keyboard time inp.keydown(function(event){ switch(event.keyCode){ case 13: td .html($(this).val()); //Use Ajax to transmit data to the server //Get all column objects in a row var tds=td.parent("tr") .children("td"); var i=tds.eq(0).text(); var n=tds.eq(1).text(); var a=tds. eq(2).text(); var s=tds.eq(3).text(); var e=tds.eq(4).text(); //var user ={id:i,name:n,age:a,sex:s,email:e} $.post("save.php",{id:i,name:n,age:a,sex: s,email:e},function(data){ alert(data); }); break; case 27: td.html(data); break; } }).blur(function(){ td.html($(this).val()); //Use Ajax to transfer data to the server //Get all column objects in a row var tds=td.parent("tr").children("td"); var i=tds.eq(0).text(); var n=tds.eq(1).text(); var a=tds.eq(2).text(); var s=tds.eq(3).text(); var e=tds.eq(4).text(); //var user={id:i,name:n,age:a,sex:s,email:e} $.post ("save.php",{id:i,name:n,age:a,sex:s,email:e},function(data){ alert(data); }); }); }); });
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