简体   繁体   English

如何在 Javascript 和 HTML 中单击按钮时制作新画布

[英]How to make new canvases on button click in Javascript and HTML

So I have these buttons: https://i.stack.imgur.com/qc90A.png Everytime I click on each button I want to make a new canvas with +1 z-index.所以我有这些按钮: https://i.stack.imgur.com/qc90A.png每次单击每个按钮时,我都想制作一个带有 +1 z-index 的新 canvas。 I do not know how to make and use dynamic variables.我不知道如何制作和使用动态变量。

let canvas = createElement('canvas')
canvas.style.height = height
canvas.style.width = width
canvas.style.zIndex = 1
document.body.append(canvas)

Run the following code with different height and width on each respective button.在每个相应的按钮上运行以下具有不同高度和宽度的代码。 I have not tested this, but it should work我没有测试过这个,但它应该可以工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM