The event object received by all event handlers has a timeStamp
property which contains the (again) timestamp in milliseconds.
You can keep that value to know how much time passed since last event.
You can also create your own timestamp by calling new Date().getTime
().

--
Ariel Flesler
http://flesler.blogspot.com

On Jan 4, 10:45 am, Mads <mads...@gmail.com> wrote:
> I'm working on spicing up a search bar so it loads the results through
> an ajax call. I throws the request whenever a keyup event has been
> fired in the input field, my code looks like this:
>
> inputValue = jQuery("input#s").val();
> url = "http://www.iconpark.net/?s="; + inputValue + " #content > *";
>        jQuery("#content").slideUp(800, function() {
>                 jQuery("#content").load(url,{},function() {
>                         jQuery("#content").slideDown(500, function() {
>                                 
> jQuery('p:contains("'+inputValue+'")').each(function(){
>                                         
> jQuery(this).html(jQuery(this).html().replace(new RegExp
> (inputValue,'g'), '<span class="highlighted">'+inputValue+'</span>'));
>                                 });
>                         });
>                         
> jQuery.getScript("http://www.iconpark.net/wp-content/themes/
> PixelResort/javascript/myScripts.js");
>                 });
>         });
>
> I works fine, it wraps the search results with <span
> class="highlighted"></span>, however, at the moment it creaets as many
> <span> tags as key-up events so I'm wondering if there is a to
> calculate the time that has elapsed since last key-up event so I could
> call the jQuery code that hightlights the search results only when a
> second has passed since last kep-up event?

Reply via email to