So I was able to load Jquery in the head of the doc very easily. I have three rectangles that are different colors. When the user clicks on any of the rectangles, a label (#label_top) changes the color of the rectangle that was clicked.
So I just added a function to the rectangles on mouse click:
I did this for all three buttons and it works fine - I just changed the hex value to the button color. Then I wanted to set up different layouts and it started getting tedious. I decided to write a function that I can just call, it would find the hex value of the element that was clicked and then assign it to the label. That way I can just write one function and assign it to all the buttons.
Anyway, I tried a couple different approaches - .this etc. and I’m not getting it to work.
So here’s the question:
What is the best way to refer to the current element as a variable? So I’d be creating a variable, assigning the current element’s color to it and then assigning that color to #label_top.
I have a feeling my error is in syntax, but also wanted to ask so I find the best workflow from the beginning.