I am using the following function on a website. Excusing the sloppy jQuery I'm using, is there any way to run this function multiple times without declaring it as a standalone function and without copying and pasting the code several times?
Exhibit A:
setTimeout(function(){
$('.nav > li > a').each(function(k,el){
var width = $(this).parent().width();
$(this).next('span').width(width);
});
},1000);
I don't want to do this:
setTimeout(function(){
// same code here
},1000);
setTimeout(function(){
// same code here
},3000);
setTimeout(function(){
// same code here
},5000);
Nor do I want to do this:
function myfunction{
// same code here
}
setTimeout('myFunction()',1000);
setTimeout('myFunction()',3000);
setTimeout('myFunction()',5000);