[英]How to cache HTMLElement.focus in a variable?
What is the correct context to store the focus
function of an HTMLElement in a variable? 将HTMLElement的focus
功能存储在变量中的正确上下文是什么?
I tried, 我试过了,
var elem = document.getElementById('elem');
var focus = elem.focus.bind(document); // focus() Illegal Invocation
var focus2 = elem.focus.bind(elem); // focus2() Illegal Invocation
Wrap it into your own function: 将其包装到您自己的函数中:
var elem = document.getElementById('elem');
var focusElem = function(){ elem.focus(); };
focusElem();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.