<html>
<head>
<meta http-equiv="Content-Type" content="text/html charset=UTF-8">
<script class="jquery library" src="/js/sandbox/jquery/jquery-1.8.2.min.js" type="text/javascript"></script>
<title>
RunJS 演示代码
</title>
<script>
jQuery(function($){
$("ul>li>a").click(function(){
$(this).next("ul").toggle().closest("li").siblings("li").children("ul").hide()
}).next("ul").hide()
})
</script>
</head>
<body>
<ul>
<li>
<a>
一级菜单
</a>
<ul>
<li>
隐藏的二级菜单项
</li>
<li>
隐藏的二级菜单项
</li>
<li>
隐藏的二级菜单项
</li>
</ul>
</li>
<li>
<a>
一级菜单
</a>
<ul>
<li>
隐藏的二级菜单项
</li>
<li>
隐藏的二级菜单项
</li>
<li>
隐藏的二级菜单项
</li>
</ul>
</li>
<li>
<a>
一级菜单
</a>
<ul>
<li>
隐藏的二级菜单项
</li>
<li>
隐藏的二级菜单项
</li>
<li>
隐藏的二级菜单项
</li>
</ul>
</li>
</ul>
</body>
</html>
window.onload=function(){var odiv = document.getElementById('div1')
odiv.onmouseover = function () {
startMove(300)
}
odiv.onmouseout = function () {
startMove(100)
}
function startMove(itarget){
var odiv=document.getElementById('div1')
var ispeed=(itarget-odiv.offsetWidth)/10
var timer = setInterval(function(){
if(ispeed>=0){
Math.ceil('ispeed')
if (odiv.offsetWidth == 300) {
clearInterval(timer)
} else{
odiv.style.width = odiv.offsetWidth + ispeed + 'px'
}
}else{
Math.floor('ispeed')
if (odiv.offsetWidth == 100) {
clearInterval(timer)
} else{
odiv.style.width = odiv.offsetWidth + ispeed + 'px'
}
}
}, 30)
}
}
</script>