输入框功能不起作用

0 html javascript input function

我是一个新手,在学习编码,所以请耐心等待...我试着制作一个代码,从输入框中获取文本并将其写为h1标题.但代码不起作用.请告诉我什么是错的......

<!Doctype html>
<html>
<head>
</head>
<body>
<input type="text" id="txtJob" value="software engineer">
<button type="button" onclick="myFunction()">HERE</button>
<script>
function myFunction(){
var id=document.getElementById("txtJob").value;
document.write("<h1>"+id+"</h1>);
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

Mri*_*jay 5

这条线

document.write("<h1>"+id+"</h1>);
Run Code Online (Sandbox Code Playgroud)

失踪".

document.write("<h1>"+id+"</h1>"); //this will work
Run Code Online (Sandbox Code Playgroud)