Reputation: 61
After adding text in the input fields and clicking on the button is not triggering click event. But clicking on the button triggers 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" />
Upvotes: 4
Views: 2785
Reputation: 61
Setting a timer that delays the blur action fires the 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" />
Upvotes: 2