I'm trying to get the animation to work in this simple Jquery hide/show program. But when I hide the content and press "less...", there is no animation, just plain transition. I worked on this little thing for hours, but no success. Any suggestions?
<!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/