Focusout doesn't work on mobile when keyboard button is pressed, but does work on clicking on document

$('#something').on("focusout", function(ev) {
   if(ev.type == "focusout"){alert('Working');}
});
      

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type='text' id='something'>
      

Run codeHide result


This code works great with large screen devices. But when I try to use it on mobile devices, after typing anything, when I click a button (mobile keyboard button), nothing happens when I click on the document (mobile browser screen) it works fine, Same if I just wrote something, but instead of clicking I click on the document, it works fine.

I am using Opera Mobile Emulator

, is this problem only for Opera Browser

?

+3


source to share


1 answer


function submitForm(e) {
    alert('form submitted');
    
    e.preventDefault();
}

(function() {
    var form = document.getElementsByTagName('form')[0];
    
    form.addEventListener('submit', submitForm);
}());
      

<form>
    <input type="text" id="start" name="start">
    <input type="submit" value="Done">
</form>
      

Run codeHide result




I have checked this above code in android and the form is submitted on the Enter button. Please, try.

0


source







All Articles