As I try to use setInterval function input fields in bootstrap modal get focus out
setInterval(function(){
console.log("hi");
}, 5000);
input focus automatically out while try to write in an input field.
This answer might not be what you're looking for, and I'm not sure a real answer can be given but putting code in comments is ugly. Read comments for info about the question itself.
Below the code that resembles my production case and with the "fix" (for my case) in it.
setTimeout(function() {
// Any var declarations don't seem to matter
var foo = null;
// Easy way out ... if needed you can delay to do stuff onBlur
// Find current focused element and escape if its an input
if (document.activeElement.nodeName === 'INPUT') {
return;
}
// Here some random style change that triggered the bug
randomFunc();
}, 210);
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.