I just want to once and for all get some clarity on jQuery within Wordpress as I can never remember from one project to the next how things should be done.
The particular example I am talking about is for flexslider. On the site I am working on now I have tried:
jQuery(document).ready(function($) {
$('.flexslider').flexslider({
slideshow: true,
animationSpeed: 400,
initDelay: 100,
animation: "slide",
animationLoop: true,
itemWidth: 258,
itemMargin: 26
});
});
This works in Opera but not Firefox, and have tried:
jQuery(document).ready(function($) {
jQuery('.flexslider').flexslider({
slideshow: true,
animationSpeed: 400,
initDelay: 100,
animation: "slide",
animationLoop: true,
itemWidth: 258,
itemMargin: 26
});
});
This works in Firefox but not Opera, other browsers not yet tested.
What is the correct way to do this to work in all browsers?
Thanks
<script defer src="<?php bloginfo('template_url'); ?>/jquery.flexslider.js"></script> <script type="text/javascript"> (function($){ "use strict"; $(document).ready(function(){ $('.flexslider').flexslider({ slideshow: true, animationSpeed: 400, initDelay: 100, animation: "slide", animationLoop: true, itemWidth: 258, itemMargin: 26 }); }); })(this.jQuery); </script>