Add animation to jQuery
2 answers
What do you want to do in all jQuery plugins . The idea is to add your function to prototype
jQuery to be aliased as $.fn
. You do it like this:
$.fn.myFadeOut = function(){
return this.animate({opacity: '0'}, 200, function() {
$(this).animate({height: '0'}, 200, function() {
$(this).remove();
});
});
}
+1
source to share
You can create your own jQuery function using the property fn
:
$.fn.removeElement = function() {
return this.each( function() {
$(this).animate({opacity: '0'}, 200, function() {
$(this).animate({height: '0'}, 200, function() {
$(this).remove();
});
});
});
};
Using:
$( '#someElement' ).removeElement();
0
source to share