Prev Demo
Onclick Of Canvas Rectangle
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <canvas id="Canvas1" onclick="color()" style="border: 5px solid green"></canvas> <script> var c = document.getElementById("Canvas1"); var b = c.getContext("2d"); b.fillStyle = "yellow"; b.fillRect(100, 30, 80, 90); function color() { { alert("Hello am yellow color") } } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output