日期:2014-05-16 浏览次数:20660 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> </HEAD> <BODY> <TABLE border="1" width="100"> <TR> <TD id="td">text</TD> </TR> </TABLE> <SCRIPT LANGUAGE="JavaScript"> var obj=document.getElementById("td"); td.onclick=function(){ this.innerHTML="<input type='text' value='"+this.innerHTML+"'>"; } </SCRIPT> </BODY> </HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> </HEAD> <BODY> <TABLE border="1" width="100"> <TR> <TD id="td">text</TD> </TR> </TABLE> <SCRIPT LANGUAGE="JavaScript"> var obj=document.getElementById("td"); td.onclick=function(){alert(this.firstChild.tagName) if (this.firstChild && !this.firstChild.tagName) this.innerHTML="<input type='text' value='"+this.innerHTML+"'>"; } </SCRIPT> </BODY> </HTML>
------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<TABLE border="1" width="100">
<TR>
<TD id="td">text</TD>
</TR>
</TABLE>
<SCRIPT LANGUAGE="JavaScript">
var obj=document.getElementById("td");
td.onclick=function(){
this.innerHTML="<input type='text' onclick='return false' value='"+this.innerHTML+"'>";
}
</SCRIPT>
</BODY>
</HTML>
------解决方案--------------------
直接去除onclick事件。。。。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> </HEAD> <BODY> <TABLE border="1" width="100"> <TR> <TD id="td">text</TD> </TR> </TABLE> <SCRIPT LANGUAGE="JavaScript"> var obj=document.getElementById("td"); td.onclick=function(){ this.innerHTML="<input type='text' value='"+this.innerHTML+"'>"; this.onclick=null; } </SCRIPT> </BODY> </HTML>
------解决方案--------------------
<SCRIPT LANGUAGE="JavaScript"> var obj=document.getElementById("td"); obj.onclick=function(){ this.innerHTML="<input type='text' value='"+this.innerHTML+"' onclick='return false'>"; } </SCRIPT>
------解决方案--------------------
http://topic.csdn.net/u/20090929/21/314549cd-adcf-41a1-91b2-4eaf2ae0aebf.html