If you put a keydown event on your input, you can trig the focusout event if the pressed key is "tab" and do what you want. Else the focusout will be triggered by a clic.
Change event type
-
14-07-2023 - |
Pregunta
I'm trying to get the type of change of an element.
<input type="text" onchange="fn()"/>
<script>
function fn() {
if (event.isKeyPress)
// do something
else if (event.isClick)
//do something else
</script>
So in full, I'm changing a text field, then to change, the user has to unfocus the field and change its contents. I want to find the manner at which it was unfocused (e.g. by tab or click). Is this possible?
NOTE: I am using jQuery.
Solución
Otros consejos
You can use Keydown. See: http://www.javascripter.net/faq/onkeydown.htm or http://www.w3schools.com/jsref/event_onkeydown.asp
$('input').focus(function(){
// something..
}).change(function(){ // or keyup
// do something awesome
}).focusout(function(){
// that's it
});
$( "input" ).focusout(function() {
// do something
})
http://api.jquery.com/focusout/
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow