我正在尝试在同一个网站上使用jQuery砌体3次。每个代码块都独立工作,但是当尝试同时使用全部3时,只有最后一个工作。如何将这些结合起来,同时保持每个不同的值和选择器?
/** First Instance **/
var $container = $('.smallcolwrap');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector : '.smallcol',
columnWidth: function( containerWidth ) {
return containerWidth / 3; },
isAnimated: true
});
});
/** Second Instance **/
var $container = $('.slickr-flickr-gallery');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector : 'li',
columnWidth: 160,
isAnimated: true
});
});
/** Third Instance **/
var $container = $('.navigationHome');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector : 'li',
columnWidth: function( containerWidth ) {
return containerWidth / 2; },
isAnimated: true,
animationOptions: {
duration: 250,
easing: 'linear',
queue: false
}
});
});
答案 0 :(得分:2)
/** First Instance **/
var $container = $('.smallcolwrap');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector : '.smallcol',
columnWidth: function( containerWidth ) {
return containerWidth / 3; },
isAnimated: true
});
});
/** Second Instance **/
var $container1 = $('.slickr-flickr-gallery');
$container1.imagesLoaded(function(){
$container1.masonry({
itemSelector : 'li',
columnWidth: 160,
isAnimated: true
});
});
/** Third Instance **/
var $container2 = $('.navigationHome');
$container2.imagesLoaded(function(){
$container2.masonry({
itemSelector : 'li',
columnWidth: function( containerWidth ) {
return containerWidth / 2; },
isAnimated: true,
animationOptions: {
duration: 250,
easing: 'linear',
queue: false
}
});
});