This article describes the method of editing div node names by js. Share it for your reference. The specific implementation method is as follows:
The node html code is as follows:
<input type="image" class="img_1" src="img/"></input>
<div class="noteText" type="text" ondblclick ="changeName();">123</div>
</div>
js edit noteTxt text, the function is as follows:
var noteTxt = (noteTxtId);
= "none";//.= "block"
var div = ;
if(!("noteInput")){
var text=("input");
="text";
="noteInput";
=getStyle(noteTxt,'width');
=getStyle(noteTxt,'height');
=getStyle(noteTxt,'marginTop');
=getStyle(noteTxt,'textAlign');
=;
(text);
();
=function(){
= "block";
=;
//= "none";
(text);
}
}
}
//Get the style in the css file
function getStyle(obj, attr)
{
if()
{
return [attr]; //IE
}else{
return getComputedStyle(obj,false)[attr]; //FF
}
}
CSS is as follows:
width: 80px;
height:70px;
position:absolute;
}
.noteText {
width:80px;
height:15px;
text-align:center;
margin-top:70px;
word-break:break-all;
}
I hope this article will be helpful to everyone's JavaScript programming.