I’ve made a small function that I’ll be reusing several times in an application. It seems like I’ve written the syntax wrong because my console is showing an eror “Object [object Object] has no method ‘fadeIt’
So I imagine the issue is passing the object of one function into another.. not sure how to do it gracefully. My code is below.
Thanks for your help!
http://jsfiddle.net/danielredwood/aFx6u/2/
function fadeIt() {
$(this).animate({
opacity:0
}, 400, function(){
//$(this).css('cursor','auto');
//$(this).children('img').css('margin-left','-100px');
});
}
$('.box').click(function(){
$(this).fadeIt();
}):
You probably want to make this into a plugin and use the following approach:
$.fn.fadeIt = function() {
};
then you can use $(this).fadeIt();