Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67497

Wordpress can read javascript file but does not execute a particular function used

$
0
0

I have a site called clients.rebiz.com/wise

enter image description here

The product menu has a drop down menu attached to it. The problem is that when the site is viewed on the mobile, an arrow is attached next to the Product and only by clicking the arrow can the dropdown be accessed. Now many users on mobile devices will surely click the product tab first and then the arrow. The products menu links to a "#" and a click event is attached to the arrow.

enter image description here

I am using a child theme and have attached the following javascript in the theme and enqueued via function.php

    jQuery("#menu-main-navigation-new-1 .products-list >a").toggle(
     function(e){
     e.preventDefault();
     jQuery(".sub-menu").slideToggle(); 
     jQuery('i.lastudioicon-down-arrow').addClass('lastudioicon-up-arrow active').removeClass('lastudioicon-down-arrow');
},
     function(e){
     e.preventDefault();
     jQuery(".sub-menu").slideToggle();
     jQuery('i.lastudioicon-up-arrow').addClass('lastudioicon-down-arrow').removeClass('lastudioicon-up-arrow active');  
 });

I have tested this code snippet in the developers console and it works as intended. The problem is that it does not work when attached to wordpress. I have tested out different alerts and prompts in the code which indicates that wordpress can infact read this file. There is no conflict error indicated in console as well.

I viewed similar problems that could occur because of contact form 7 but testing out indicated no such error.

Long story short, the javascript snippet works but it does not work when attached with wordpress albeit wordpress having confirm access to the javascript file.


Viewing all articles
Browse latest Browse all 67497

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>