单击我进行编辑
<div onclick="edit(this)">单击我进行编辑</div>
var titleEditing = false
function edit(element) {
console.log(titleEditing)
if (titleEditing) {
return
}
titleEditing = true
old = element.innerHTML
element.innerHTML = ""
var newObj = document.createElement("textarea")
newObj.className = "textArea"
newObj.innerHTML = old
element.append(newObj)
newObj.focus()
newObj.onblur = function() {
element.innerHTML = this.value ? this.value : old
titleEditing = false
}
}