因为pinterest小部件不能在android平板电脑上运行,所以我想从Magnific弹出窗口将data-pin-no-hover="true“(pinterest)添加到img容器
这是我的代码
/**
* jQuery Magnific Popup (http://dimsemenov.com/plugins/magnific-popup/)
**/
$('.open-gallery-link').click(function(event) {
event.preventDefault();
$('.mfp-container img').attr('data-pin-no-hover', 'true');
var items = [];
$($(this).attr('href')).find('a').each(function() {
items.push( {
src: $(this).attr('href'),
title: $(this).attr('alt'),
img: $('.mfp-container img').attr('data-pin-no-hover', 'true')
} );
});
$.magnificPopup.open({
type:'image',
preload: [0,2],
items:items,
gallery: {
enabled: true
},
});
});有人知道解决方案吗?
发布于 2014-08-06 14:36:53
只有在打开弹出窗口后,
.mfp-container才在DOM中可用。change )来访问当前项http://dimsemenov.com/plugins/magnific-popup/documentation.html#events的内容
发布于 2014-08-06 19:59:26
这似乎很管用。作为参考,我的解决方案
/**
* jQuery Magnific Popup (http://dimsemenov.com/plugins/magnific-popup/)
**/
$('.open-gallery-link').click(function(event) {
event.preventDefault();
var items = [];
$($(this).attr('href')).find('a').each(function() {
items.push( {
src: $(this).attr('href'),
title: $(this).attr('alt')
} );
});
$.magnificPopup.open({
type:'image',
preload: [0,2],
callbacks: {
change: function() {
this.content.find('.mfp-img').attr('data-pin-no-hover', 'true')
},
},
items:items,
gallery: {
enabled: true
},
});
});https://stackoverflow.com/questions/25128089
复制相似问题