Possible Duplicate:
Unselect what was selected in an input with .select()
Is there a way to detect when a user unselects text in an input element via jQuery?
(Note: I am not asking about detecting "unselection" -- that is, blur -- of the input element itself, but about the text within the element.)
I am doing
$('#input').select(function () {...}
to show a toolbar with formatting options when the user selects text, but I have not been able to figure out how to detect if the user clears the selection.
Any suggestions?
Try the blur Event
$('#input').on('blur',function () {
if( this.value == ''){
alert('Blur Event - Text box Empty');
//Your code here
}
});
This will fire as soon as the Input field loses the focus.. i.e; it was unselected..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With