Jquery 放大弹出窗口打开项目数组中的特定项目
我有一个类似以下内容的项目数组:Jquery 放大弹出窗口打开项目数组中的特定项目,jquery,magnific-popup,Jquery,Magnific Popup,我有一个类似以下内容的项目数组: items: [ { src: '#white-popup0', type: 'inline' }, { src: '#white-popup1', type: 'inline' }, { src: '#white-popup2', type: 'inline' }] <div id="white-popup0" class="white-popup"> <div class="popup_so
items: [
{
src: '#white-popup0',
type: 'inline'
},
{
src: '#white-popup1',
type: 'inline'
},
{
src: '#white-popup2',
type: 'inline'
}]
<div id="white-popup0" class="white-popup">
<div class="popup_social_buttons">
<iframe src="//www.facebook.com/plugins/like.php"><!-- FB like button --></iframe>
<a href="//www.pinterest.com/pin/create/button/"><!-- Pinterest button --></a>
<div id="___plusone_3" ><!-- G+ button --></div>
</div>
<img alt="alt text here" src="some_picture.jpg" class="img-responsive">
<button title="Close (Esc)" type="button" class="mfp-close">×</button>
</div>
和一些html内容来匹配该数组,看起来有点像这样:
items: [
{
src: '#white-popup0',
type: 'inline'
},
{
src: '#white-popup1',
type: 'inline'
},
{
src: '#white-popup2',
type: 'inline'
}]
<div id="white-popup0" class="white-popup">
<div class="popup_social_buttons">
<iframe src="//www.facebook.com/plugins/like.php"><!-- FB like button --></iframe>
<a href="//www.pinterest.com/pin/create/button/"><!-- Pinterest button --></a>
<div id="___plusone_3" ><!-- G+ button --></div>
</div>
<img alt="alt text here" src="some_picture.jpg" class="img-responsive">
<button title="Close (Esc)" type="button" class="mfp-close">×</button>
</div>
×
html内容对于每个“#白色弹出窗口”具有相同的结构。
现在,我打开放大弹出窗口的方法是从一个引导旋转木马中触发.magnificpoup函数,在这个旋转木马中,我有与我的数组中相同数量的项目。我需要做一些事情,从我的js数组中触发某个项目。例如,如果我单击旋转木马中的第二个项目,我将打开所有项目,但从第二个项目开始
提前感谢。打开方法有一个可选的第二个参数,即要打开的项目的索引
$.magnificPopup.open({
items: [
{
src: '#white-popup0',
type: 'inline'
},
{
src: '#white-popup1',
type: 'inline'
},
{
src: '#white-popup2',
type: 'inline'
}]
}, 2);
open方法似乎不再支持简单地为index添加可选的第二个参数。我猜这是从一个较旧版本的放大镜,因为它似乎没有工作 根据文档,现在可以在选项中包含索引参数 这对我有用
$.magnificpoop.open({
项目:[
{
src:“#白色弹出0”,
键入:“内联”
},
{
src:“#白色弹出框1”,
键入:“内联”
},
{
src:“#白色弹出框2”,
键入:“内联”
}],
索引:2
});代码>这正是我想要的,非常感谢。