有谁能告诉我为什么我的onchange或onkeypress不起作用?似乎根本没有调用该函数。
<canvas id="myCanvas" width="400" height="400" style="border:1px solid #000000;"></canvas>
X:<input type="number" id="boxwidth" onChange="myfunction()"/>
Y:<input type="number" id="boxheight" onkeypress="draw()"/>
脚本:
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
context.rect(20, 20, 150, 100);
alert("Hello! I am an alert box!");
context.stroke();
function myfunction(){
alert("Hello! I am an alert box!");
}