There is a code of a navigation bar with a list with links leading to the block id
, and blocks with the contents of the pages. How to implement that when you click on a link, the element of the list was assigned a class .active
, and for a block with an id
to which the link leads, the class .hidden
while all other blocks with the class .page
this class.
<div class="navbar"> <ul class="nav"> <li class="active"><a href="#home">Link</a></li> <li><a href="#page1">Link</a></li> <li><a href="#page2">Action</a></li> <li><a href="#page3">Another action</a></li> <li><a href="#page4">Something else here</a></li> </ul> </div> <div id="home" class="page"> ΡΡΡΠ°Π½ΠΈΡΠ° Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΡΠΌ home </div> <div id="page1" class="page hidden"> ΡΡΡΠ°Π½ΠΈΡΠ° Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΡΠΌ page1 </div> <div id="page2" class="page hidden"> ΡΡΡΠ°Π½ΠΈΡΠ° Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΡΠΌ page2 </div> <div id="page3" class="page hidden"> ΡΡΡΠ°Π½ΠΈΡΠ° Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΡΠΌ page3 </div> <div id="page4" class="page hidden"> ΡΡΡΠ°Π½ΠΈΡΠ° Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΡΠΌ page4 </div>