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