<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0 /jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(
function()
{
$("#b1").click(function(){
$("p").hide();
})
$("#b2").click(function(){
$("p").show();
})
$("#fade").click(function()
{
$("p").fadeOut(2000);
})
$("#fade1").click(function()
{
$("p").fadeIn(5000);
})
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.
If you click on me, I will disappear.
If you click on me, I will disappear.
If you click on me, I will disappear.
If you click on me, I will disappear.
If you click on me, I will disappear.
If you click on me, I will disappear.
If you click on me, I will disappear.
</p>
<input type="button" value="Hide" id="b1"/>
<input type="button" value="Show" id="b2"/>
<input type="button" value="Fade" id="fade"/>
<input type="button" value="Fade" id="fade1"/>
</body>
</html>
Replace Click() with hover().
使用'slideToggle'兩次是不可靠的,可能會導致一些不良結果 – Bloafer
不錯的提示,10倍。更改爲sludeDown/sludeUp –
你是什麼意思好提示,更像是我的好回答。請參閱下面我的未經編輯的答案。 – Bloafer