Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nav hover add class and remove using javascript smooth

 <script>
  
   
       const megaMenuShow = document.querySelectorAll('.top-menu-nav-a');
       let megaMenuSH = document.querySelector('.megaMenu');
   
	   //  nav hover show menu
       megaMenuShow.forEach( cc=> {
		
         cc.addEventListener('mouseover', function(e){
             let data_mega = cc.getAttribute('data-mega');
             let currentMenu = document.querySelector(`.${cc.getAttribute('data-mega')}`);
           
             if(currentMenu != null){
                 
                  const menuHide = document.querySelectorAll('.megaMenu');
                  menuHide.forEach( cc => cc.classList.remove('megaMenuShowHide'));
                  e.preventDefault();
                  currentMenu.classList.add('megaMenuShowHide');
                  megaMenuOver(data_mega);
             }
         });
         
         cc.addEventListener('mouseout', function(e){
             const menuHide = document.querySelectorAll('.megaMenu');
             menuHide.forEach( cc => cc.classList.remove('megaMenuShowHide'));
         });


       });
   
   		function megaMenuOver(data_mega){
          
          let megaMenuSHide = document.querySelector(`.megaMenu.${data_mega}`);
           
          	 megaMenuSHide.addEventListener('mouseout',function(e){
               megaMenuSHide.classList.remove('megaMenuShowHide');
             });
          
             megaMenuSHide.addEventListener('mouseover',function(e){
               megaMenuSHide.classList.add('megaMenuShowHide');
             });
        }

   
 </script>  
Comment

PREVIOUS NEXT
Code Example
Javascript :: multiple variables in one live javascript 
Javascript :: create user controller 
Javascript :: mongoose auto delete after time 
Javascript :: Number o flines of typography element react material 
Javascript :: folder array randomizer 
Javascript :: Laravel Vue.js API: axios, FormData() is empty 
Javascript :: React Router rendering blank pages for all components 
Javascript :: javascript axios response.data.pipe not a function 
Javascript :: Examples of correct code for the { "typeof": true } option with global declaration: 
Javascript :: count object based on status and shop using javascript 
Javascript :: angularjs Uncaught ReferenceError: myFunction is not defined at HTMLInputElement.onkeyup 
Javascript :: call method from parent 
Javascript :: Easy Angular way to detect if element is in viewport on scroll 
Javascript :: when selecting second dropdown ng-model object return null 
Javascript :: react-native navigation stack set push component then cover parent page 
Javascript :: .push( ) is not updating the variable 
Javascript :: ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AuthModule)[AuthService - AuthService - AngularFirestore - InjectionToken 
Javascript :: JavaScript delete atray item 
Javascript :: disconnect google colab runtime 
Javascript :: filter number from string in javascript 
Javascript :: online jquery converter 
Javascript :: Create A Class Using JavaScript 
Javascript :: get longi and long with an adress react 
Javascript :: chrome page transitions 
Javascript :: Second Simplest Promise Example 
Javascript :: number of substring in a string 
Javascript :: unhide is not working with radio button javascript 
Javascript :: how to find default or the first server discord.js 
Javascript :: mul function call to 3 functions 
Javascript :: get data from multiple api in react 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =