I've got the functionality that allows you to open and close the hidden dropdown that you can see in the link but I want to also be able to close the already open dropdown if you click the same image again.
At the moment I can only close the ones on the outside of the clicked element.
Main fragment of code (wired up on ready), complete working sample - JsFiddle:
function close() {
$('.slide').removeClass("active");
$('.slide').css("padding-bottom", 0 + "px");
}
function open() {
$(this).addClass("active");
$(this).css("padding-bottom", height);
}
$('.slide').on('touchstart click', function() {
close();
if ( $(this).hasClass("active") ) {
close();
}
if ( !$(this).hasClass("active") ) {
$(this).addClass("active");
$(this).css("padding-bottom", height);
}
});
HTML:
<div class="slide"> title
<div class="js-slide">content of slide hidden via CSS when
"active" class is not present</div>
</div>