日期:2014-05-16 浏览次数:20419 次
<SCRIPT LANGUAGE="JavaScript"> function setd(e,value) { e = e||window.event var key = e.charCode||e.keyCode if(key==13) document.getElementById("d").innerHTML=value; } </SCRIPT> <INPUT TYPE="text" onkeyup="setd(event,this.value)"> <div id=d onclick="alert(this.innerHTML)">aaaaa</div>
------解决方案--------------------
<html > <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <body> <SCRIPT LANGUAGE="JavaScript"> function setd(e,value) { e = e||window.event var key = e.charCode||e.keyCode if(key==13) document.getElementById("d").innerHTML=value; } function ShowTxt() { document.getElementById("txt").style.display="block"; } </SCRIPT> <INPUT id="txt" TYPE="text" style="display:none" onkeyup="setd(event,this.value)"> <div id="d" onclick="ShowTxt()">aaaaa</div> </body> </html>
------解决方案--------------------
我又看错问题内容了……
<div id="test" onclick="demo()">aaaaaa<div> <script> function demo(){ var str=document.getElementById('test').firstChild.data; str = "<input name='testInput' type='text' onkeyup='setd(event,this.value)' value='"+str+"' onblur='enter(this.value)'>"; document.getElementById('test').onclick=function(){}; document.getElementById('test').innerHTML=str; } function enter(value){ document.getElementById("test").innerHTML=value; document.getElementById('test').onclick = demo; } function setd(e,value) { e = e||window.event var key = e.charCode||e.keyCode if(key==13) { document.getElementById("test").innerHTML=value; document.getElementById('test').onclick = demo; } } </script>