HTML:
<input>
JavaScript using jQuery:
$('input').focusin(function(){
alert('input focused')
});
Very strange behavior: when using jQuery to make a simple alert when an <input> or <textarea> gains focus, it causes the alert to repeat anywhere from 3 times all the way up to repeating 57 times. It’s random, and that’s without changing any code, sometimes it alerts 14 or 26 or 35 etc.
Does anyone know why this happens? Am I missing something?
Edit: just realized this is happening in Chrome, but firefox 4 isn’t repeating the alert.
The input probably loses it’s focus when the alert pops up, and regains it when it’s closed, causing it to fire again.
Try using
console.log("input focus");or any other means to see the event fire without making use of an alert and see if the problem still occurs.