HTML里的onfocus事件处理函数

174 阅读1分钟
<html>
<style>
div {
	margin:20px;
	height: 70px;
	border: 1px solid green;
	outline: 1px solid red;
	outline-offset: -4px;
}

:focus {
	background-color: blue;
};
</style>

<script>

function focused(event){
	debugger;
	console.log('event: ' + event);
}
</script>
<body>
	<div tabindex="3">3</div>
	<div tabindex="-1">0</div>
	<button onfocus="focused(event)">test</button>
</body>
</html>

成功触发:

事件类型为focus:

对应的是onblur:


更多Jerry的原创文章,尽在:“汪子熙”: