tags:

views:

55

answers:

2

Alright, I have a div which is 50px (height), and the width does not matter that has a title displayed. I want to use jquery, so when I hover over the div it expands upwards to (70px) to reveal the content hidden below the title

<div id="box">
<h1>Title Goes Here</h1>
<p>this is the hidden text</p>
</div>
A: 
$("#box").hover(function(){
    $("#box").css('height','70px');
}, function(){
    $("#box").css('height','50px');
});

EDIT: I just understood how you want to expand only upwards. I have just a solution for this, if your design permits this: use position:absolute and a bottom:x value. The box will expand upward

cripox
Stop posting solutions without formatting them correctly or any explanation whatsoever. Also, the solution's syntax is obviously wrong, and even if it works, it's not answering the OP's questions - he want's slide, ie. animation, and also *upward* - this given no context would simply slide downwards
Yi Jiang
1) I tried to format corectly, that's why I edited my post. 2) I just seen that he wants it to be upwards so I came to put a comment for this: if your design permits using a position:absolute and a bottom:x should do the trick
cripox
@cripox You shouldn't use the `code` tag here - `code` is for inline code in HTML - you're looking for `pre`, and anyway Stack Overflow uses Markdown, which is cleaner than HTML - have a look at this http://stackoverflow.com/editing-help
Yi Jiang
@Yi the syntax was wrong first and the formatting was not correct, but I edited my answer in a couple of minutes: formated and corrected the syntax. I just hit the add button quickly to see if I can be the first answer (i answered 3 posts and while I was writing there were many other answers) - so this was kind of an experiment. Sorry, I didn't thought you will be checking it so quick.
cripox
@cripox - Being the first to post isn't very useful if it's not a valid answer :) Post a *useful* answer quickly and that's great, but if it's not even formatted (which you can do in one button click) that's just a lack of effort IMO.
Nick Craver
@nick Yes, you are right, I just told that it was an experiment, and also I was going to edit it right away.
cripox
@Cripox, thanks for your input@Ender, thanks! Helped a lot. I should have thought of adding the "-20" to it..
Louis Stephens
@Louis Stephens - my pleasure
Ender
+2  A: 

This snippet should do the trick:

$(function() {
    $("#box").hover(function() {
        $("#box").animate({'height': '70px', 'top': "-20px"});
    }, function() {
        $("#box").animate({'height': '50px', 'top': "0px"});
    });
});

Here's a live demo: http://jsfiddle.net/MeBxJ/

Ender