Slide Up on click
Slide Up on click
Hey.. have a quick question. Im really new to jQuery and am working on a simple little script to help me figure it out but im a little stumped.
I have the following script that when you click on the div it expands upwards but what I want to do is have it expand if you click on a link which will also be displayed on the page. (so if you click "click here" then the div will expand upwards).
Heres my code
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://dev.jquery.com/view/tags/ui/latest/ui/effects.core.js"></script>
<script src="http://dev.jquery.com/view/tags/ui/latest/ui/effects.slide.js"></script>
<script>
$(document).ready(function(){
// animate both height and top position to simulate bottom up animation.
// subtract starting height of div from end height of div
// use the difference as the default top position
// in this case (start height) 50px - (end height) 400px = (start top position) 350px
$("div").click(function () {
$(this).animate({
height: "400",
top: "0"
}, 1500 );
});
});
</script>
<style>
div {
margin: 0px;
width: 200px;
height: 50px;
background: black;
border: 1px solid black;
position: relative;
top: 350px;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
Any help would be awesome. Thanks -
Douglas Mellon