Conflict between Jquery and "scroll to top" function
-
Hi Armin, hi Marius.
I'm experimenting an issue with a thing I wanted to put into my website.This is my problem: I'm trying to put this JS code in order to change a word randomly with a series of other words.
This is the code I put into the "head" section.<script type="text/javascript"> // Array of words var words = ['*', 'web' , 'graphic' , 'visual' , 'digital' , 'icon' , 'logo' , 'UI' , 'UX' , 'editorial' , 'infographic' , '(basic) illustration' , '(basic) video' , 'type' ]; // Function that executes every 2000 milliseconds var t = setInterval(function() { // Random number generator var randomNumber = Math.round( Math.random() * (words.length-1) ); // Change the word in the span for a random one in the array of words $('#changing').html( words[ randomNumber ] ); }, 2000); </script>
Unfortunately, if I put only this code it doesnt' work,
So I tried to add this thing because I supposed the function needed Jquery:<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
And eventually the trick worked, but after that implementation I saw that the "scroll to top" feature doesn't work anymore.
So, what can I do if I want to keep both things full working but at the same time avoiding that kind of conflicts?
Thanks a lot.
Jacopo -
Dear @jacopoeffe
Have a look here: http://laytheme.com/documentation.html#custom-javascript There is everything written you need to know for working with Javascript or jQuery in LayTheme.
Best!
Marius -
Thank you @mariusjopen , i found the perfect solution for my problem, and it worked perfectly!
"When using jQuery, please use 'jQuery' instead of '$'"
Great, thanks for your suggestion & help.
Have a nice Easter.
Jacopo -
Dear @jacopoeffe
classic…
Great!
Best!
Marius
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it