my question is two functions are passed to toggle why.. and out side another function is there that is also confusing plz tell me
$('#login a').toggle(function() {
$(this)
.addClass('active')
.next('form')
.animate({'height':'show'}, {
duration:'slow',
easing: 'easeOutBounce'
});
}, function() {
$(this)
.removeClass('active')
.next('form')
.slideUp();
});
$('#login form :submit').click(function() {
$(this)
.parent()
.prev('a')
.click();
});
The toggle() method takes two (or more) functions as arguments and calls one of them alternately each time the element is clicked.
Functions are first class citizens in Javascript: you can manipulate them like any other object, including passing them to other functions:
function foo(otherfunction)
{
otherfunction();
}
function bar()
{
window.alert("bar() was called.");
}
foo(bar); // Ultimately calls `bar()`.
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