Ale*_*lex 3 javascript jquery lightbox jquery-selectors
我有一个普通的html页面,其中包含div和图像链接:
<div>
<a href="foo.jpg"> ... </a>
<a href="boo.jpg"> ... </a>
</div>
<div>
<a href="bah.jpg"> ... </a>
<a href="gah.jpg"> ... </a>
</div>
...
Run Code Online (Sandbox Code Playgroud)
我正在尝试在所有以jpg/gif/png扩展名结尾的链接上挂钩灯箱脚本.
现在,根据我问过的上一个问题:),我有:
$('div a').filter(function(){
return this.href.match('[\.jpg|\.png|\.gif]$');
}).colorbox({
rel: 'gallery'
});
Run Code Online (Sandbox Code Playgroud)
它将所有链接分组gallery.
但是我希望将自己画廊中每个div的链接分组.例如.foo'和.boo链接在a gallery1和.bah&.gah里面gallery2等等......
我怎样才能做到这一点?
$('div').each(function(index) {
$(this).find('a').filter(function(){
return this.href.match('[\.jpg|\.png|\.gif]$');
}).colorbox({
rel: 'gallery' + index
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1342 次 |
| 最近记录: |