web前端|js教程
js,编辑,div节点,名称,方法
web前端-js教程
本文实例讲述了js实现编辑div节点名称的方法。分享给大家供大家参考。具体实现方法如下:
centos下android源码下载,vscode退出代码为2,ubuntu搭建plex,tomcat 7配置线程,豆瓣爬虫星级,快速学会php,seo推广计划类型可以分为,网站后台模板视频,Bootstrap响应式后台管理模板lzw
节点html代码如下:
php新闻公告系统源码,vscode背景半透明,ubuntu怎么画,tomcat防止攻击,sqlite整理数据库,爬虫能放在加热垫上吗吗,php的数学函数,日照seo优化报价,关闭网站后弹窗代码,flash网页教程,php 个人购物模板lzw
html下载站源码,离线安装 vscode,ubuntu忘记,tomcat禁用ip,sqlite时间日期函数,网站分享插件,客户端前端用什么框架,厨房碗柜里有白色爬虫,PHP 缓存 内存,政和专业seo排名,怎么破解网站后台权限,网页手机端模板下载,织梦列表页模板lzw
123
js编辑noteTxt文本,function如下:
function changeName(noteTxtId){
var noteTxt = document.getElementById(noteTxtId);
noteTxt.style.display= "none";//.style.display= "block"
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, extAlign);
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);
}
}
}
//获得css文件中的样式
function getStyle(obj, attr)
{
if(obj.currentStyle)
{
return obj.currentStyle[attr]; //IE
}else{
return getComputedStyle(obj,false)[attr]; //FF
}
}
css如下:
.img_1 {
width: 80px;
height:70px;
position:absolute;
}
.noteText {
width:80px;
height:15px;
text-align:center;
margin-top:70px;
word-break:break-all;
}