<script>
function accordion() {
var div = document.getElementById('content');
var divs = div.getElementsByTagName('p');
var i = 0;
var t = null;
for(i = 0; i < divs.length; i++) {
divs[i].index = i;
divs[i].onmouseover = function() {
var index = this.index;
if(t) {
clearInterval(t);
}
t = setInterval(function() {
var iWidth = 500;
for(i = 0; i < divs.length; i++) {
if(index != divs[i].index) {
var iSpeed = (50 - divs[i].offsetWidth) / 5;
iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
divs[i].style.width = divs[i].offsetWidth + iSpeed + 'px';
iWidth -= divs[i].offsetWidth;
}
}
divs[index].style.width = iWidth + 'px';
}, 30);
};
}
}
accordion();
</script>
js手风琴效果
最新推荐文章于 2024-07-17 23:28:09 发布