Multiple Methods in a jQuery Event -
i'm having difficulty writing jquery code. i'm trying pass multiple methods through event handler $(foo).click(methodone , methodtwo); purpose of first method fade out current view , hide , purpose of second method display alternate view. whatever reason click accepting 1 method, , i'm quite positive can accept @ least 2. here 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()
accept 1 function. (and i'm pretty sure)
but can work on you're trying do.
your code simplified below,
$(".slide1,.slide0").click(fadeout); function fadeout() { $(this).stop() .fadeto("medium", 0) .hide() .fadeto("medium", 1); }
which gives me scratch in head. what trying yo achieve??
or maybe looking .toggle()
?
Comments
Post a Comment