Help with jQuery click event to change background color | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Help with jQuery click event to change background color

I set a div (class=ā€œitemā€ id=ā€œbackā€) I set css with jQuery ā€œ(document).readyā€ Itā€™s fine so far, the problem comes when I want to use addClass to this div after clicking another div (id=ā€œjoyasā€) It goes like: $(document).ready(() => { $(ā€œ#backā€).addClass(ā€œindexbackā€); }); $(ā€œ#joyasā€).click(function() { $(ā€œ#backā€).addClass(ā€œjoyasbackā€); }); Notes: .indexback class has linear gradient, and I want it to change to white when clicking the div ā€œjoyasā€. So the class .joyasback has a solid white background.

13th Aug 2022, 1:50 AM
BASSiT Music
BASSiT Music - avatar
1 Resposta
+ 2
Can you attach the code bit link please? incomplete snippet like this make it harder to find the problem cause there are things that aren't shown. https://www.sololearn.com/post/75089/?ref=app
13th Aug 2022, 2:18 AM
Ipang