I am unsure if this is a "callback' that I need or not, but basically I am trying to emulate the reversal of the function like on the .hover() effect with the .click() effect. Is this possible. So basically, if the user clicks again on the link, the reverse of what just happened, ie a div closing as opposed to opening, will happen. Is it possible to do this with .click()?
$(document).ready(function(){
$('.content_accrd').css({"height":"0px"});
$('.paneltop').click( function() {
$(this).css({"background-position":"0px -21px"})
.siblings().animate({"height":"100px"}, 200)
}, function() {
$(this).css({"background-position":"0px 0px"})
.siblings().animate({"height":"0px"}, 200);
})
})
Use .toggle(), not .click().
Description: Bind two or more handlers to the matched elements, to be executed on alternate clicks.
try toggle
$(".paneltop").toggle(function(){
//first click happened
},function(){
//second click happened
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With