标签:rip lang element edit function fun return doctype var
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>JS edit</title></head><body><div> </div> <div onClick="edit(this)">nanjing</div> <script> var titleEditing = false function edit(element) { console.log(titleEditing) if(titleEditing){ return } titleEditing = true let 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 } } </script> </body> </html>
标签:rip lang element edit function fun return doctype var
原文地址:https://www.cnblogs.com/tigerhsu/p/11509974.html