March 14, 20179 yr Hi all, I'm not the best with jquery but basically I have a WordPress site that is using Rev Slider and I have added the following snippet of code to adjust some divs on resize: <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script> $(window).resize(function() { if ($(window).width() < 1100) { $('.swap-one').insertAfter('.swap-two'); } else{ $('.swap-one').insertBefore('.swap-two'); } }); </script> The CDN was copied from an example I found, not sure what should be the correct jquery version, but basically there is an issue with this and the slider, they don't seem to work together. Here is a link to the site. Rev slider looks like it's using this: .../wp-includes/js/jquery/jquery.js?ver=1.12.4'></script> My code is in the footer. Thanks, Al.
March 14, 20179 yr Rev slider is horrible plugin - it's become bloated and clunky and conflicts with all sorts of things. However, if the theme already uses jQuery you don't need to call it again. And Wordpress doesn't like $ in jQuery functions. Change $ to jQuery in the snippet. And you should try to enqueue your scripts rather than add them to the theme files. This is an excellent tutorial on how to do it properly (and hopefully avoid conflicts): https://premium.wpmudev.org/blog/adding-scripts-and-styles-wordpress-enqueueing/
March 14, 20179 yr Rev slider is horrible plugin - it's become bloated and clunky and conflicts with all sorts of things. However, if the theme already uses jQuery you don't need to call it again. And Wordpress doesn't like $ in jQuery functions. Change $ to jQuery in the snippet. And you should try to enqueue your scripts rather than add them to the theme files. This is an excellent tutorial on how to do it properly (and hopefully avoid conflicts): https://premium.wpmudev.org/blog/adding-scripts-and-styles-wordpress-enqueueing/ You can use the Dollar sign just fine with wordPress. you need to ensure you wrap all your code in a closure and properly alias it. (function($) { // use dollar sign all you like here. })(jQuery); It's pretty verbose to use jQuery everywhere so make sure it's in scope like it will be in the example above.
March 14, 20179 yr You can use the Dollar sign just fine with wordPress. you need to ensure you wrap all your code in a closure and properly alias it. A much better explanation than my poor attempt.
Create an account or sign in to comment