所以我试图能够输入整数,将它们推入一个数组,然后显示该数组。但是我无法显示它。我不知道如何显示一个小格式的段落。我需要隐藏段落,然后在我按下按钮时显示它或创建它并用文本填充它。谢谢
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p>enter integers</p>
<input type="text" name="hello" id="f">
<button onclick="push()" class= "push">push</button>
<button onclick="displaybut()" class="displaybut">display</button>
</body>
<script src="script.js"></script>
</html>
let button = document.querySelector(".push");
let inp = document.querySelector("input");
var arr = [];
function push(){
if (inp.value != ""){
arr.push(inp.value);
inp.value = ''
}
console.log(arr);
}
let para = document.createElement("p");
function displaybut(){
para.innerHTML = "This is the final array"+ arr ;
}