在上边双击文章题目可以编辑标题,以实现更换标题功能。
代码:
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 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";
}
效果:
提示:可以先在文本框内,根据需要修改代码后再运行