The example in this article describes the method of editing div node names in js. Share it with everyone for your reference. The specific implementation method is as follows:
The node html code is as follows:
var div = noteTxt.parentNode;
if(!document.getElementById("noteInput")){
var text=document.createElement("input");
text.type="text";
text.id="noteInput";
text.style.width=getStyle(noteTxt,'width');
text.style.height=getStyle(noteTxt,'height');
text.style.marginTop=getStyle(noteTxt,'marginTop');
text.style.textAlign=getStyle(noteTxt,'textAlign');
text.value=noteTxt.innerHTML;
div.appendChild(text);
text.select();
text.onblur=function(){
noteTxt.style.display= "block";
noteTxt.innerHTML=text.value;
//text.style.display= "none";
div.removeChild(text);
}
}
}
//Get the style in the css file
Function getStyle(obj, attr)
{
If(obj.currentStyle)
{
return obj.currentStyle[attr]; //IE
return getComputedStyle(obj,false)[attr]; //FF
}
}
Width:80px;
height:15px;
Text-align:center;
Margin-top:70px;
Word-break:break-all;
}