I'm trying to use jQuery to expand and contract the height of a div when a link is clicked, and I can't for the life of me work out what I'm doing wrong.
Here's the html;
<div id="slider" class="map">
<div id="map-canvas">this is a test</div>
</div>
<div id="slider-map"><a href="#" id="expand">Expand +</a></div>
The slider height is 300px by default in the CSS
Here's the jQuery;
$(document).ready(function() {
var maxWidth = 500;
var minWidth = 300;
$("#expand").click(
function(){
var curHeight = $("#slider").height();
if(curHeight==300)
{
$("#slider").animate({height: maxWidth+"px"}, { queue:false, duration:400 });
$("#expand").html("Contract <small style='font-size:12px;'>-</small>");
}
else
{
$("#slider").animate({height: minWidth+"px"}, { queue:false, duration:400 });
$("#expand").html("Expand <small style='font-size:12px;'>+</small>");
}
return false;
});
}
I've tried this without calling the Google maps API in the map-canvas div too see if that was the culprit, but it still won't work.
Any help would be much appreciated