+ 2

HTML, CSS + JS. How can I add certain styles to the clicked element, and a different style to the un-clicked element. see descri

Overall, it’s about active button, and page at the same time. When button x is active, page x is active too, and they get a style different than the other btns, and pages. <button> a </button> <button> b </button> <button> c </button> <div> page a </div> (x3) How can accomplish this: when button “a” is clicked, button “a” gets style X, and page “a” gets style Y. The other btns and pages don’t (or do) get a style. Similar situation when the other buttons are clicked. I’ve started the code here: https://code.sololearn.com/WZKWh2c4hBpc/?ref=app

27th May 2020, 7:26 AM
Ginfio
Ginfio - avatar
6 Respuestas
+ 5
Ginfio This is a nice question, and has a nice answer :)) Check out the corrected code : https://code.sololearn.com/WsjkVOGcx1Oq/?ref=app
27th May 2020, 9:24 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 3
Normally we use JavaScript for element control, sometime we can use css only. Check this out. https://code.sololearn.com/WckzRCX2jMda/?ref=app
27th May 2020, 1:06 PM
Calviղ
Calviղ - avatar
+ 2
I think you should use css for that. By use :link{ background-color: ; Color: ;} :active{ } :hover{ } and :visited{ } Link is for links yet to be visited. Active for already visited links. Hover for highlighted links. And visited for already visited links. I hope this would be helpful bro.
27th May 2020, 9:12 AM
Infinite
Infinite - avatar
+ 2
Thanks y’all.
27th May 2020, 7:51 PM
Ginfio
Ginfio - avatar
+ 1
Calviղ is that the same as click event listener? It doesn’t really matter, but ... i’m just wonderin
28th May 2020, 2:36 AM
Ginfio
Ginfio - avatar
+ 1
Ginfio Same effect in this case.
28th May 2020, 3:01 AM
Calviղ
Calviղ - avatar