I am working with JQuery and I'm trying to change the html of a div box when the child div slides in and out. My problem is that the code below isn't changing the html value of #menu_text. It only displays Hide Menu and is not detecting the real height as changed by slideToggle.
$('#menu').click(function () {
$('#menu_links').slideToggle('slow', function(){
console.log('Debug : %s', $('#menu_links').height());
if ($('#menu_links').height() == 1)
$('#menu_text').html("Show Menu");
else if ($('#menu_links').height() == 20)
$('#menu_text').html("Hide Menu");
});
});
Upon inspection in firebug console, The value of height never changes from 20 unless you click the div really fast multiple times then it will change to 1. (I should add that the height defined in the style sheet is 20)
The doc says that slideToggle only affects the height of the object. Am I missing something? Thank you for the help.
<div id="menu"><p id="menu_text">Show Menu</p>
<div id="menu_links">
Stuff
</div>
</div>