0
我想有一個按鈕在畫布上顯示矩形。但是在腳本被調用後這會被清理掉。畫布一旦完成屏幕清除
<!DOCTYPE html>
<html>
<body>
<form>
<br>depth = : <input type="number" id="depthValue" name="depthValue" value="2"><br>
<input type="submit" value="Submit" onclick="calculate()">
</form>
<canvas id="canvas" width="1000" height="1000" style="background-color:#EE2"></canvas>
<script>
function calculate() {
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "rgb(255, 0, 0)";
ctx.fillRect(0,0,300,300);
}
</script>
</body>
</html>
矩形出現,但立即消失。
最新情況?
內聯是它顯示了當你按回車鍵,然後消失? – Gacci