Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

add and remove active class

links.forEach((link)=> {
 	 /*
  		*important may you face an problem that's becuase the arow function
 		doesn't work here.
        --so dont use arow function--
 	*/
    link.addEventListener('click', function(){
        links.forEach((e)=> {e.classList.remove('active')})
        this.classList.add('active')
    })
}) 
 
PREVIOUS NEXT
Tagged: #add #remove #active #class
ADD COMMENT
Topic
Name
4+9 =