简体   繁体   中英

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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