我正在学习自己编写代码并使用javascript启动但是我的代码有问题但无法找到问题请解释我为什么我的代码用javascript结果替换html文档中的所有元素< / p>
<!DOCTYPE html>
<meta name="robots" content="noindex">
<html>
<head>
<title>JS</title>
</head>
<body>
<h1> Whats your name? </h1>
FirstName: <input type="text" id="first" value="">
LastName: <input type="text" id="second" value="">
<button onclick="myFunction()">Submit</button>
<script id="jsbin-javascript">
function myFunction() {
var first = document.getElementById("first").value;
var second = document.getElementById("second").value;
var fullName = first + " " + second;
var x = fullName;
console.log(x);
document.write(x);
}
</script>
</body>
</html>