Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

first remove active class from classlist and append to current element using javascript

function myFunction(e) {
  if (document.querySelector('#navList a.active') !== null) {
    document.querySelector('#navList a.active').classList.remove('active');
  }
  e.target.className = "active";
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Ckeditor get content html 
Javascript :: deploy create react app pm2 
Javascript :: javascript before reload page alert 
Javascript :: hide warnings in expo app 
Javascript :: javascript encode url to decode C# 
Javascript :: javascript keep only letters in string 
Javascript :: how to format numbers as currency string js 
Javascript :: regular expression should not contain special character 
Javascript :: custom error js 
Javascript :: js add delay 
Javascript :: javascript array key value html select 
Javascript :: useMutation on success function not being called 
Javascript :: newtonsoft json deserialize c# example 
Javascript :: var socket = io(); reconnect 
Javascript :: exit application node js 
Javascript :: count occurrences of character in string javascript 
Javascript :: xmlhttp js post request 
Javascript :: add keyup event javascript 
Javascript :: javascript size of variable in kb 
Javascript :: do more than one thing at start of or loop javascript 
Javascript :: fill array with 0 javascript 
Javascript :: get offset of element relative to parent 
Javascript :: JavaScript the last word of a string 
Javascript :: style display block js 
Javascript :: js console log without spaces 
Javascript :: npm i react query 
Javascript :: jquery :not class 
Javascript :: split integer into digits javascript 
Javascript :: array traversal backward 
Javascript :: jquery datepicker set year range 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =