JavaScript中onfocus事件的用途是什么?
当元素获得焦点时触发onfocus事件。您可以尝试运行以下代码,以了解如何在JavaScript中实现onfocus 事件。
示例
<!DOCTYPE html>
<html>
<body>
<p>Write below:</p>
<input type = "text" onfocus = "newFunc(this)">
<script>
function newFunc(x) {
x.style.background = "blue";
}
</script>
</body>
</html>热门推荐
10 业主装修完成祝福语简短
11 官宣祝福语简短霸气
12 五一快乐祝福语简短老师
13 新年孕妈祝福语简短
14 朋友买新房祝福语简短
15 走正路的祝福语简短
16 小学立秋祝福语大全简短
17 对公司年会祝福语简短
18 写给女友的祝福语++简短