触发onfocus事件时,显示p item上text的值。

Display the value of text on p item when the event onfocus is triggered.

我想在触发事件onfocus 时显示p 项上文本字段的值。我究竟做错了什么?先感谢您!

<input type="text" id="test1" name="test2" value="hello" onfocus="myFunction()">
    <p id="test3"></p>

function myFunction() {
    var x=document.getElementByID("test1").value;
    document.getElementByID("test3").innerHTML=x;
}

Here is the code

getElementByID 是错误的大小写。用 getElementById 替换它(注意小写 d 作为最后一个字符。