"Bad element for masonry: undefined" why this error us occuring?

I am developing a WordPress Theme using masonry. but it generates following error on index page

"Bad element for masonry: undefined"

and these two errors on single.php

"Bad element for masonry: undefined"
"Bad element for masonry: null"

Here is the code i am using in my theme

jQuery(window).load(function() {

      // MASSONRY Without jquery
      var container = document.querySelector('#ms-container');
      var msnry = new Masonry( container, {
        itemSelector: '.ms-item',
        columnWidth: '.ms-item',
      });

    });

 $(function(){
          "use strict";
    var m = new Masonry($('.grid').get()[0], {
        itemSelector: ".masonary"
    });

});

is there any clue about this issue?

Topic masonry theme-development Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.