سؤال

I am trying to load some jquery on window load however I recieve the error of 'jQuery is not defined'.

Here is my jquery.

jquery(function($) { //jQuery passed in as first param, so you can use $ inside
jquery(window).load(function ($) {
    $('#newsPost').masonry({
      columnWidth: '.col-lg-6',
      itemSelector: '.item'
    });      
})
});

I had it working fine with document ready however window load is coming up not defined.


Here is an update showing the final working version:

jQuery(function($) { 
$(window).load(function () {
$('#newsPost').masonry({
  columnWidth: '.col-lg-6',
  itemSelector: '.item'
});      
})
});
هل كانت مفيدة؟

المحلول

Replace jquery with jQuery or $.

Or

Are you sure you have loaded jquery script file ?

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top