var height = $('.grid-container').data('height');
console.log(height);
<div class="grid-container" id="8-2" data-delay="8" data-position="row1" data-height="217" data-width="253" data-state="start" style="position: absolute; -webkit-transition: width 0.5s, height 0.5s; transition: width 0.5s, height 0.5s; opacity: 1; width: 256px; left: 0px;">
返回undefined。怎么回来undefined?
帮助表示赞赏
更新
wall.reset({
selector: '.grid-container',
animate: true,
cellW: 255,
cellH: function(){
var height = $('.grid-container').data('height');
return height;
},
delay: 0,
gutter: 15,
onResize: function() {
wall.fitWidth();
wall.refresh();
}
});
使用freewall我试图从数据高度获取高度以正确放置网格。帮助赞赏
更新#2
您会看到图像彼此更接近 - 它应该与http://vnjs.net/www/project/freewall/example/pinterest-layout.html具有相同的外观。
不确定我哪里出错了。
帮助表示赞赏。
答案 0 :(得分:1)
您的代码对于获取数据高度是正确的。你很可能没有在正确的地方调用它(即没有加载div时)。在准备好的文档上编写代码。
$(document).ready(function(){
var height = $('.grid-container').data('height');
console.log(height);
})
答案 1 :(得分:0)
尝试使用height():
var height = $('.grid-container').height()