Is there any declare for toggle() that if its open do this, closed to that?
Posted
by
Dejan.S
on Stack Overflow
See other posts from Stack Overflow
or by Dejan.S
Published on 2012-10-09T15:02:20Z
Indexed on
2012/10/09
15:38 UTC
Read the original article
Hit count: 167
JavaScript
|jQuery
Im doing some jquery stuff with toggle()
, I'm doing different actions depending on if the current div
is closing or showing, i know i can easy check if a div hasClass()
or is(':visible')
for what i want to do, but I'm thinking maybe there is somehow that i can reduce the amount of code or just do it more efficient? like declare the toggle() with two functions that this is for when its showing and this is for when its closing, is this possible?
hope you get what i mean?
like this, or check a jsfiddle
$('#click_me').on('click', function() {
$('#contain').toogle('blind', 300, function (){
alert('open');
}, function (){
alert('close');
});
});
© Stack Overflow or respective owner