【发布时间】:2014-07-30 15:10:34
【问题描述】:
我是这里的新手,正在学习编码,所以请多多包涵... 我试图制作一个从输入框中获取文本并将其写为 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>
【问题讨论】:
-
你没有在上关闭'"'
-
非常感谢它的工作!!!非常感谢大家的回答!
标签: javascript html function input