I am struggling to implement two buttons - one for expanding a div and one for collapsing it. Despite multiple attempts to modify the code, I have not been successful. It appears that I am having trouble understanding how to prevent a link from toggling.
Additionally, I want the DIV to be visible when the page loads. I am uncertain if this can be achieved with my current coding approach.
If anyone can provide guidance on what steps I need to take to make this functionality work, I would greatly appreciate it.
I am aiming to avoid using .slideUp/.slideDown as they appear to be conflicting with another plugin on the page.
$('#click-meopen').click(function() {
var height = $("#this").height();
if( height > 0 ) {
$('#this').css('height','0');
} else {
$("#this").css({'position':'absolute','visibility':'hidden','height':'auto'});
var newHeight = $("#this").height();
$("#this").css({'position':'static','visibility':'visible','height':'0'});
$('#this').css('height',newHeight + 'px');
}
});
$('#click-meclose').click(function() {
var height = $("#this").height();
if( height > 0 ) {
$('#this').css('height','0');
} else {
$("#this").css({'position':'absolute','visibility':'hidden','height':'auto'});
var newHeight = $("#this").height();
$("#this").css({'position':'static','visibility':'visible','height':'0'});
$('#this').css('height',newHeight + 'px');
}
});