I've got follow code:
$(document).ready(function() { let element = $('.inputField'); element.on({ 'input': function(e) { console.log('input'); }, 'blur': function(e) { console.log('blur'); } }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input class="inputField"> <input> <button>Click here</button>
I use two events
on my input
. The first event is the input
. I use this to detect if something was written in my input. The second one is the blur
. With this event I detect if the focus
on my input was lost (for example with tab into next input) or if the user clicked outside the input (for example on the button). Now this works fine on chrome
. I also need it on internet explorer
, but there the blur doesn't work. I looked at this questions:
jQuery blur() or focusout() not firing in Internet Explorer
Blur event not working in IE11 and IE10
I could not find a solution to my problem. Any ideas? Thanks
尝试使用ES5语法替换ES6。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.