I am uncertain why this code is not functioning. The goal is to hide an image and show another one in its place when the user clicks .accent. The currently displayed image (which is shown on page load) is referenced by the class .ssi-hide.
Here is the jQuery:
jQuery(document).ready(function($){
// jQuery methods go here...
var currentImage = '".ssi-hide"';
$(".accent").click(function() {
swapImage( currentImage, "#accent-img" );
});
}); //end jQuery
and here is the function:
(function( $ ) {
$.fn.swapImage = function( outPic, inPic ) {
$( outPic ).fadeOut(200, function(){
$( inPic ).fadeIn(400).css("display", "block").css("margin", "auto");
});
currentImage = inPic;
};
})( jQuery );
Chrome is notifying that: "Uncaught ReferenceError: swapImage is not defined" as well as "Uncaught Error: Syntax error, unrecognized expression: ".ssi-hide""
Thank you very much for any help.
$(this).swapImage(currentImage, "#accent-img");$.fn.swapImagereally should be$.swapImagesince you're not acutally using the instance your defining it on. then you call$.swapImageinstead of$(this).swapImage