html⽂本框追加内容,html⽂本框
var oA = ElementById('box');
var oB = ElementById('tijiao');
var oC = ElementById('ul1');
var oLi = ateElement('li'); //createElement是HTML中应⽤W3C DOM对像模型建⽴⼦节点也就是⼦元素的概念!oLi.innerHTML = oA.value;
var aLi = ElementsByTagName('li');
if (aLi.length > 0) {
oC.insertBefore(oLi, aLi[0]); //iE不兼容,因为不到aLi[0],所以不知道往谁前⾯加
} else {
oC.appendChild(oLi);
}
//运动
html内容文本框
var iHeight = oLi.offsetHeight - 2;
oLi.style.height = '0';
startMove(oLi, {
height: iHeight
}, function() {
startMove(oLi, {
opacity: 100
})
})
}
}
function getStyle(obj, name) {
if (obj.currentStyle) {
return obj.currentStyle[name];
} else {
return getComputedStyle(obj, false)[name];
}
}
//startMove(oDiv, {width: 400, height: 400})
function startMove(obj, json, fnEnd) {
clearInterval(obj.timer);
obj.timer = setInterval(function() {
var bStop = true; //假设:所有值都已经到了
for (var attr in json) {
var cur = 0;
if (attr == 'opacity') {
cur = und(parseFloat(getStyle(obj, attr)) * 100); } else {
cur = parseInt(getStyle(obj, attr));
}
var speed = (json[attr] - cur) / 2;
speed = speed > 0 ? il(speed) : Math.floor(speed); if (cur != json[attr]) {
bStop = false;
}
if (attr == 'opacity') {
obj.style.filter = 'alpha(opacity:' + (cur + speed) + ')';
obj.style.opacity = (cur + speed) / 100;
} else {
obj.style[attr] = cur + speed + 'px';
}
}
if (bStop) {
clearInterval(obj.timer);
if (fnEnd) {
fnEnd();
}
}
}, 30);
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。