I'm using this line of code quite a bit:
.hide().insertBefore("#placeholder").fadeIn(1000);
Is there a way to make this a function or variable (pretty sure can't use a var, but thought I'd ask) so I can call it as needed? I know I could just copy/paste, but it clutters up the code to see that over and over.
I tried:
function properDisplay() {
.hide().insertBefore("#placeholder").fadeIn(1000);
}
But that doesn't work.
You can make it a plugin:
$.fn.properDisplay = function(){
return this.hide().insertBefore("#placeholder").fadeIn(1000);
};
Usage:
$('#SomeElement').properDisplay();
You need to pass the element object as parameter
function properDisplay(ele) {
$(ele).hide().insertBefore("#placeholder").fadeIn(1000);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With