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 建工系毕业祝福语简短