JQuery focusout doesn't fire onclick event
After adding text to input fields and clicking the button, no click event is fired. But clicking on the button raises the click event.
$("#title").focusout(function() {
alert('foucus out');
});
$("#ok").click(function() {
alert('click');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Title
<input id="title" val="hello" />
<input id="ok" type="button" value="OK" />
+3
source to share
1 answer
Setting a timer that delays the blur action raises a click event.
$("#title").focusout(function() {
setTimeout(function() {
alert('foucus out');
}, 500);
});
$("#ok").click(function() {
alert('click');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Title
<input id="title" val="hello" />
<input id="ok" type="button" value="OK" />
+1
source to share