Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
69
rated 0 times [  71] [ 2]  / answers: 1 / hits: 16377  / 10 Years ago, wed, august 6, 2014, 12:00:00
<input id=ok /> 

$('.hor-minimalist-a').on('blur','#ok',function(){

});


with this code above, i can handle events which fire If i leave the input field.



How can I detect if someone clicks outside of inputfield without coming to input. I mean the user never came to this input field before, so there was no focus at all.



$('.hor-minimalist-a').on('?','#ok',function(){
?
});

More From » jquery

 Answers
78
$(document).on('click', function(e) {
if ( e.target.id != 'ok' ) {
// you clicked something else
}
});


That would capture any click except on the input, but why would you need it ?



To capture only clicks on .hor-minimalist-a and not the entire document, just replace document with that selector in the code above.


[#69885] Tuesday, August 5, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
arturo

Total Points: 331
Total Questions: 99
Total Answers: 92

Location: Austria
Member since Thu, Jan 7, 2021
3 Years ago
;