复制代码 代码如下: <BR>$(function() { <br><br>$("td").dblclick(function() { //获取标签 <BR>var td = $(this); <BR>var itemid=td[0].id; <BR>var txt = td.text(); <BR>var input = $("<input type='text' value='" + txt + "'/>"); <BR>td.html(input); <BR>input.click(function() { return false; }); <BR>//获取焦点 <BR>input.trigger("focus"); <br><br>input.blur(function() { <BR>var newtxt = $(this).val(); <br><br>if (newtxt != txt) { <BR>td.html(newtxt); <BR>var caid = $.trim(td.prev().text()); <br><br>/*这里做ajax去后台操作 <br><br>var url = "?a.php&itemid=" + itemid + "&v=" + newtxt; //具体根据网站情况而定 <br><br>$.get(url, function(data) { <BR>if(data=="1") <BR>{ <BR>location.reload(); <BR>td.html(txt); <BR>return; <BR>} <BR>td.html(newtxt); <BR>}); <br><br>} <BR>else <BR>{ <BR>td.html(newtxt); <BR>} <BR>}); <br><br>*/ <br><br>}); <BR>}); <BR>