div元素能实现获取焦点的方法:
给div元素添加一个 tabindex属性,这个属性的取值范围为≥0的整数。tabindex属性值越小(最小为0)其所在的标签越先得到焦点
<style>
div{
width: 100px;
height: 100px;
outline:none;
background-color: #f00;
}
</style>
</head>
<body>
<div tabindex="1"></div>
<script>
var oDiv=document.querySelector("div")
oDiv.onfocus=function(){
oDiv.style.backgroundColor="blue"
}
</script>