JQuery按钮时间求助
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var docked = 0;
$("#dock li ul").height($(window).height());
$("#dock .dock").click(function(){
$(this).parent().parent().addClass("docked").removeClass("free");
docked += 1;
var dockH = ($(window).height()) / docked
var dockT = 0;
$("#dock li ul.docked").each(function(){
$(this).height(dockH).css("top", dockT + "px");//给定高度
dockT += dockH;
});
$(this).parent().find(".undock").show();
$(this).hide();
if (docked > 0)
$("#content").css("margin-left","250px");
else
$("#content").css("margin-left", "60px");
});
$("#dock .undock").click(function(){
$(this).parent().parent().addClass("free").removeClass("docked")
.animate({left:"-180px"}, 200).height($(window).height()).css("top", "0px");
docked = docked - 1;
var dockH = ($(window).height()) / docked
var dockT = 0;
$("#dock li ul.docked").each(function(){
$(this).height(dockH).css("top", dockT + "px");
dockT += dockH;
});
$(this).parent().find(".dock").show();
$(this).hide();
if (docked > 0)
$("#content").css("margin-left", "250px");
else
$("#content").css("margin-left", "60px");
});
$("#dock li").hover(function(){
$(this).find("ul").animate({left:"40px"}, 200);
}, function(){
$(this).find("ul.free").animate({left:"-180px"}, 200);
});
});
</script>
</head>
<body>
<ul id="dock">
<li id="links">
<ul class="free">
<li class="header"><a href="" class="dock">Dock</a>韩学文1</li>
<li><a href="">中 研 国 际</a></li>
<li><a href="">This is one item</a></li>
<li><a href="">This is one item</a></li>
<li><a href="">This is one item</a></li>
<li><a href="">This is one item</a></li>
</ul>
</li>
<li id="files">
<ul class="free">
<li class="header"><a href="" class="dock">Dock</a><a href="" class="undock">Undock</a>韩学文2</li>
<li><a href="">This is one item</a></li>
<li><a href="">This is one item</a></li>
<li><a href="">中 研 国 际</a></li>
<li><a href="">This is one item</a></li>
<li><a href="">This is one item</a></li>
</ul>
</li>
<li id="tools">
<ul class="free">
<li class="header"><a href="" class="dock">Dock</a><a href="" class="undock">Undock</a>韩学文3</li>
<li><a href="">This is one item</a></li>
<li><a href="">This is one item</a></li>
<li><a href="">中 研 国 际</a></li>
<li><a href="">This is one item</a></li>
<li><a href="">This is one item</a></li>
</ul>
</li>
</ul>
<div id="content">
<h1>中研国际中国服装培训网</h1>
<h2>Demo for <a href="">Advanced Docking using jQuery</a></h2>
</div>
</body>
上边的是代码,为什么我鼠标放上去就触发事件了呢,而不是点击触发,怎么改成点击触发啊
[解决办法]
.hover()导致放上去就触发
改成.click(()才是点击触发