我正在尝试获取变量的值并将其用于元素的宽度,但我想从中删除小数并使其成为整数。我到了这里,但似乎无法让它工作
var grid_width= width:($(window).width() / 270)
$("#grid").css({
width: grid_width.toFixed(0)
});
JS:
<script>
$('#grid').isotope({
// options
itemSelector : '.iso',
masonry: {
columnWidth: 270
},
animationEngine : 'jquery'
});
var grid_width = $(window).width() / 270;
$("#grid").css({
width: Math.floor( grid_width ) + 'px',
background: "green"
});
</script>