I have got a few jquery functions which I notice I’m repeating quite a bit of code…
For example:
function booking() {
$('#shade').fadeIn(function(){
// show booking box
});
}
function subscribe() {
$('#shade').fadeIn(function(){
// show subscribe box
});
}
What I’m curious about learning is optimising this a bit. Say the return function:
$('#shade').fadeIn(function(){});
Is it possible I could write a less wordy version of this? It turns out I’m wrapping a lot of things in this code many times so I would like to know how to put this into my own function with a return so I could simply do something like:
shade(function(){
// show booking
});
How does this work? Or is there an even more optimal way?
Sure.