Reputation: 343
im new to jquery and i want to know how to get value of an input tag when a cursor is out/left to that input element/tag. Thank you in advance.
Upvotes: 1
Views: 19775
Reputation: 3919
<form>
<input id="target" type="text" value="Field 1" />
<input type="text" value="Field 2" />
</form>
<div id="other">
Trigger the handler
</div>
<script>
$('#target').blur(function() {
alert('Handler for .blur() called.');
});
Upvotes: 1
Reputation: 55750
Use blur event
$(function() {
$('input[type="text"]').on('blur' , function() {
// Your code here
});
});
Upvotes: 13
Reputation: 209
I think the method you're searching is focusout
$(function() {
$('#input-element').focusout(function() {
// put your code here!
});
});
I hope it helps.
Upvotes: 5