Ann
Ann

Reputation: 1

Find out if the user has just moved his mouse from a input

I have some input fields on which I trigger a ajax function on their change() event.

The problem is that I manually trigger this event in certain situations, so it gets executed quite a lot.

SO how can I run my ajax ONLY when the user has typed something in the input and moved his cursor away from it?

Upvotes: 0

Views: 55

Answers (1)

SeanCannon
SeanCannon

Reputation: 78006

$('input').blur(function(){
    alert('input has lost focus'); // do ajax call here...
});

Demo: http://jsfiddle.net/Yyygr/

Upvotes: 1

Related Questions