Rectangle | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Rectangle

I have to make an application that shows an rectangle and when i click it to change the color any ideas?

12th Jun 2018, 4:53 AM
Andrei Stancu
Andrei Stancu - avatar
1 Answer
+ 3
You will just have to use an <svg> Tag in HTML. Then you would have to create a rectangle using <rect> and give rect an id. GIve the rectangle your favorite color and then use Javascript to change it. You will have to make a function which will change colors. The function will contain a variable whose value will be document.getElementById('Id').style.fill = "Color" ; Make a onclick attribute on the rect tag with value is equal to color change function. https://code.sololearn.com/WxAna6dgerpr/#html
12th Jun 2018, 5:17 AM
Akash Pal
Akash Pal - avatar