Magento – jquery not defined error in magento 2

javascriptjquerymagento2requirejstheme

I am trying to bring banner scroll in magento2. I am using owl carousel for this purpose. Everything have done and implemented and is showing in firefox without any errors. But when checked in chrome, i found jquery not defined error. After some diggings, i found we need to use call it as "require" to trigger jquery. So i have modifed the js and still firefox is rendering everything correctly, but in chrome its still the issue.
Script currently i have

require([ 'jquery', 'jquery/ui'], function($){

   $("#owl-demo").owlCarousel({
        items: 1,
        autoplay: true,
        autoplayTimeout: 5000,
        autoplayHoverPause: true,
        dots: false,
        nav: true,
        navRewind: true,
        animateIn: 'fadeIn',
        animateOut: 'fadeOut',
        loop: true
    });

});

I have tried different kinds, but every time chrome is giving me this error see

could anybody assist me in this? Thanks.

Best Answer

Try this

require([ 'jquery', 'jquery/ui'], function($){ 
$(document).ready(function($) {
   console.log('running');
   // your script
});});