Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jQuery Conflict

Featured Replies

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.

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/

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.

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.