要求是:点击表格中的某个td,这个td里面的内容变成可编辑的状态,编辑完之后,焦点离开就变回文本格式.
解决方案 »
- 关于接口隔离原则的定义,请教两个基础问题
- 实现页面后台连接sql数据库,ajax前台显示数据库表的代码
- 求教高人,GameRoles[0].MoveTo(GetPoint(x,y));
- js 远程打开word文档然怎么保存
- 自动关闭窗口并刷新父级窗口,谢谢DX
- 这个参数应该怎么提取?在线等!
- 急呀!高手帮帮忙!
- 请问给位大侠,display:none 显示的问题?
- 帮帮忙!谢谢您!!!
- Uncaught TypeError: Cannot read property 'parentNode' of undefined
- javascript/showModalDialog/弹出窗口鼠标选中文字问题/打印问题
- jquery插件的使用
var ip = $(this).find("input");
if(ip.length>0) return;
var text =$(this).text();
$(this).html("<input type='text' value='"+text+"'></input>");
$(this).find("input").focus();
$(this).find("input").blur(function(){
$(this).parent().html(this.value);
});
});<table id="tb">
<tr>
<td>abcd</td>
</tr>
</table>
基本满足条件,高手指点
<table>
<tr>
<td style="width:100px;height:30px;border:1px red solid" onclick="editme(this)">
</td>
</tr>
</table><script>
function editme(el){
var input=document.createElement('input');
input.onblur=function(){
el.innerHTML=input.value;
}
input.type="text"
input.value=el.innerHTML.replace(/\s*/g,"");
el.innerHTML="";
el.appendChild(input);
input.focus();
} </script>