Reputation: 2485
I have created two functions to accept mutiple class's and Ids to fadein and fadeout, currently it will fadeout elements fine but not fadein?
function fadeOut($element, cb) {
$element.animate({opacity:0}, 800, function(){
if (cb) cb();
});
}
function fadeIn($element, cb) {
$element.animate({opacity:1}, 800, function(){
if (cb) cb();
});
}
Example input
$("#back").click(function () {
fadeOut($('.hideToggle, .history, .apphome, .stats, #back'));
});
$("#open").click(function () {
fadeIn($('.hideToggle, .history, .apphome, .stats, #back'));
});
Upvotes: 0
Views: 236
Reputation: 3373
USe This:
$("#back").click(function () {
$('.hideToggle, .history, .apphome, .stats, #back').fadeOut();
});
$("#open").click(function () {
$('.hideToggle, .history, .apphome, .stats, #back').fadeIn();
});
Upvotes: 0
Reputation: 15070
You say you want to fadein and fadeout?
I gues you want a toggle?
$("#back, #open").click(function () {
$('.hideToggle, .history, .apphome, .stats, #back').fadeToggle();
});
Or if you want to controll them apart you can use:
$("#back").click(function () {
$('.hideToggle, .history, .apphome, .stats, #back').fadeOut();
});
$("#open").click(function () {
$('.hideToggle, .history, .apphome, .stats, #back').fadeIn();
});
Upvotes: 2
Reputation: 335
Use $(this).fadeIn() or fadeOut()
you cannot fade in and out at the same time, you can however do one after the other using the callback function.
Upvotes: 0