I’ve got a problem. I’m using jQuery 1.8.2. I want to react to a focusout event and reset the foucs to the element that was left under special conditions. Now i got this really simple codesnippet which gets caught in a loop in safari and I don’t get it why this happens… Maybe you can help me, here’s a really simple example:
JS:
$("#test").focusout( function () {
alert("FocusOut event got triggered.");
$("#test").focus();
});
HTML:
<input type="text" id="test" />
Maybe you want to try this demo:
http://jsfiddle.net/ds38v/3/ Just click into the input-box and leave it again.
There are some browser differences concerning this issue. Therefore use a timeout to “simulate” it like a “leaveFocus”- and afterwards again a “focus”-Event:
Like this it’s working.
I hope it helps…