Javascript: setTimeout() - help needed
Posted
by ilkin
on Stack Overflow
See other posts from Stack Overflow
or by ilkin
Published on 2010-04-06T11:14:39Z
Indexed on
2010/04/06
11:23 UTC
Read the original article
Hit count: 176
JavaScript
|jQuery
Hi guys, I'm currently doing a highlighting function on a webpage and im using the jquery plugin for that. My code looks like this:
var input = function() {
var matchword = $('#searchbox').val();
if(matchword != "") {
$('body').removeHighlight();
$('body').highlight($('#searchbox').val());
}
}
$(document).ready(function() {
$('#searchbox').keyup(function() {
setTimeout("input()", 2000);
});
});
It works fine if there is not so large amount of data on the page. But in case of large amount of data on the page the whole process is slowing down which causes that inputbox is freezing untill the letter is hightlighted. So the typing is not smooth. I tryed to use a setTimeout but it seems doesnt help. Any ideas?
© Stack Overflow or respective owner