0

Everyone, I wanted to insert the Product collection in my Slider for this purpose I'm using JQuery script (In the theme Header) with the HTML and CSS. The Error is "$ signed undefined" while I'm doing inspect-->Console! The below example was trying to implement. kindly guide me! enter image description here

0

Jquery and js cannot be use directly in magento 2

so you have to do something like that

require(['jquery', 'jquery/ui'], function($){
  //all you jquery code here
});
| improve this answer | |
  • <script type="text/javascript" xml="space">// <![CDATA[ require(['jquery'],function($){ $('.carousel[data-type="multi"] .item').each(function() { var next = $(this).next(); if (!next.length) { next = $(this).siblings(':first'); } next.children(':first-child').clone().appendTo($(this)); for (var i = 0; i &lt; 3; i++) { next = next.next(); if (!next.length) { next = $(this).siblings(':first'); } next.children(':first-child').clone().appendTo($(this)); } }); }); <script> // ]]></script> – Adeel Khan Apr 8 at 5:39
0

You have to created one requirejs-config.js file inside your theme like,

var config = {
    map: {
        '*': {
            owlcarousel: 'Solwin_Module1/js/owl.carousel'
        }
    }
};

And then you need to include the js code inside require function like:

<script>
require(['jquery', 'owlcarousel'], function () {
    jQuery(document).ready(function () {
        jQuery("#owl-demo").owlCarousel({
        pagination : false
         });
    });
});
</script>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.