// 添加css
document.getElementsByTagName(‘head‘)[0].innerHTML += ‘<link href="https://cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css" rel="stylesheet">‘;
<script src="https://cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js"></script>
// 获取图片列表
$(‘.detail-content-desc-box‘).find(‘img‘).each(function () {
var _this = $(this).attr(‘title‘,‘‘ + _alt + ‘‘);
var _src = _this.attr("src");
var _alt = _this.attr("alt");
_this.wrap(‘<a data-fancybox="images" href="‘ + _src + ‘"></a>‘);
})
});