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 儿子31岁祝福语简短
13 送给客户的祝福语 简短
14 祝贺新婚祝福语古代简短
15 朋友祝福语两字简短
16 中秋祝福语给父亲简短
17 预祝高尔夫的祝福语简短
18 新婚祝福语大全简短经典