この単純なJqueryの非表示/表示プログラムでアニメーションを機能させようとしています。しかし、コンテンツを非表示にして「less ...」を押すと、アニメーションはなく、単なるトランジションになります。私はこの小さなことに何時間も取り組みましたが、成功しませんでした。助言がありますか?
<!DOCTYPE html>
<head>
<style>
body{ width:50%; margin: 0 auto;}
.content{background:yellow; font-size:large; margin-top:10px;
padding:5px;}
a{text-decoration:none;}
</style>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(document).ready(function() {
$("#overflow").hide();
$(".moreorless").click(function() {
event.preventDefault();
$(this).next("#overflow").slideToggle();
if($(this).prev("#overflow").is(":hidden")){
$(this).prev("#overflow").show();
$(this).html(" less...");
}
else{
$(this).prev("#overflow").hide();
$(this).html(" more...");
}
});
})
</script>
</head>
<body>
<div class="content">
Some Lorem ipsum<span id="overflow"> and some more lorem
and more and more and more and more and more and more and more and more
more and more and more and more and more and more and more and more and
</span><a href="#top" class="moreorless"> more...</a>
</div>
</body>
</html>
jsFiddle: http: //jsfiddle.net/r5tYB/