How do I remove the focus of a TextBox in JQuery?
Edit: This is the solution I was looking for:
$(this).trigger('blur');
For an unknown reason, $(this).blur();
did not work. I created a new, clear solution and then it worked.
How do I remove the focus of a TextBox in JQuery?
Edit: This is the solution I was looking for:
$(this).trigger('blur');
For an unknown reason, $(this).blur();
did not work. I created a new, clear solution and then it worked.
$(function () {
$('input[type=text]').focus(function () {
$(this).val('');
// add the below line to trigger the blur event
$(this).trigger('blur');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<input type="text" value="abcdef">
you can force it to blur using trigger function
$("...").trigger("blur");