I’m having some difficulty with writing some jQuery code. What i’m trying to do is pass multiple methods through an event handler like so $(foo).click(methodOne , methodTwo); The purpose of the first method is to fade out the current view and then hide it and the purpose of the second method is to display an alternate view. For whatever reason click is only accepting one method, and I’m quite positive that it can accept at least 2. Here is the code:
$(document).ready(function(){
$("#slide1").hide();
$(".items img").click(function() {
if ($(this).hasClass("active")) { return; }
$(".items img").removeClass("active");
$(this).addClass("active");
$(".slide1").click(fadeOut,showSlide1);
$(".slide0").click(fadeOut,showSlide0);
});
});
function fadeOut() {
$(this).stop().fadeTo("medium", 0);
$(this).hide();
}
//Slide 0 has been clicked
function showSlide0(){
$("#slide0").stop().fadeTo("medium", 1);
}
//Slide 1 has been clicked
function showSlide1(){
$("#slide1").stop().fadeTo("medium", 1);
}
No –
.click()only accept one function. (And I’m pretty sure)But we can work on what you’re trying to do.
your code is simplified below,
Which gives me a scratch in the head. what are you trying yo achieve??
or maybe your looking for
.toggle()?