I'm trying to add lightslider(http://sachinchoolur.github.io/lightslider/index.html) in WordPress but I got error
Uncaught TypeError: jQuery(...).lightSlider is not a function(anonymous function) @ (index):99m.Callbacks.j @ jquery.js?ver=1.11.2:2m.Callbacks.k.fireWith @ jquery.js?ver=1.11.2:2m.extend.ready @ jquery.js?ver=1.11.2:2J @ jquery.js?ver=1.11.2:2
I'm trying with the simplest example from their website
HTML
<ul id="lightSlider">
<li>
<h3>First Slide</h3>
<p>Lorem ipsum Cupidatat quis pariatur anim.</p>
</li>
<li>
<h3>Second Slide</h3>
<p>Lorem ipsum Excepteur amet adipisicing fugiat velit nisi.</p>
</li>
<li>
<h3>Third Slide</h3>
<p>Lorem ipsum Excepteur amet adipisicing fugiat velit nisi.</p>
</li>
</ul>
JavaScript
<script type="text/javascript">
//Also tried to add noConflict() function
//jQuery.noConflict();
jQuery(document).ready(function() {
jQuery("#lightSlider").lightSlider();
});
</script>
Can somebody help me? Thank you!
I resolved problem. The problem exist because somehow jQuery were loaded after lightSlider.js . I don't know how this happened, I just put jQuery to load first in wp_enqueue_script(), before anything else (before css, too) and lightslider.js at the end.
I hope this answer will help someone more. Thank you for help.
I had the same problem but I have fixed it. Just copy the entire code of lightslider.js and past it into:
$(document).ready(function(){
//code of lightslider
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With