其实就是元素的替代
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>无标题文档</title>
<style>
input.a {border:1px solid #fff;background:#fff;}
input.b {border:1px solid #369;background:#fff;}
</style>
</head>
<body>
<input type="text" id="test" readonly value="这里是标题" class="a" />
<input type="submit" id="submit" value="修改" style="display:none;" />
<input type="text" id="ttt" readOnly value="这里测试2" class="a"/>
<script type="text/javascript">
var test = document.getElementById("test");
var mysubmit = document.getElementById("submit");
test.ondblclick = function(){
this.readOnly = false;
this.className = "b";
mysubmit.style.display = "";
}
mysubmit.onclick = function(){
test.readOnly = true;
test.className = "a";
this.style.display = "none";
}
var ttt = document.getElementById("ttt");
ttt.ondblclick = function(){
this.readOnly = false;
this.className = "b";
}
ttt.onblur = function(){
this.readOnly = true;
this.className = "a";
}
</script>
</body></html>