放大弹出菜单:选择特定的文件类型

Magnific Popup : select specific file types

本文关键字:文件 类型 选择 菜单 放大      更新时间:2023-09-26

我只想选择jpg文件并使用放大弹出窗口。

$('.entry-content').each(function () {
    $(this).magnificPopup({
        delegate: 'a',
        type: 'image'
    });
});

由于使用$('.entry-content'),可下载的文件无法工作。。。任何建议都是有用的。非常感谢。

您可以检查文件结尾是否为.png

$('.entry-content').each(function () {
  if($(this).attr("src").match(/'.jpg$/)) {
    $(this).magnificPopup({
      delegate: 'a',
      type: 'image'
    });
  }
});

现在可以工作了。这是我使用的代码。

$('a[href*=".jpg"], a[href*=".jpeg"]').each(function(){
    $(this).magnificPopup({
        type:'image'
    });  
});

感谢@Olander和@Brad Larson