Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript jquery: call function with parameters after timeout?

How can I call a function like this with parameters applied to it?

searchTimer = setTimeout(doSearch, 250);

function doSearch(parameter) {

}
like image 301
matt Avatar asked Dec 17 '22 18:12

matt


1 Answers

Use an anonymous function as a wrapper:

searchTimer = setTimeout(function () {
    doSearch('parameter');
}, 250);
like image 167
David Tang Avatar answered Dec 19 '22 06:12

David Tang