Colorbox - 如何仅显示特定DIV

bik*_*y77 1 jquery colorbox

我正在使用Colorbox在电子商店中展示产品,但我只想展示产品div(#prodpreview),而不是整个页面都有页眉,页脚等.

每个产品链接如下所示:

<a class="items" href="product.php?id=1" rel="items">Link to product 1</a>
<a class="items" href="product.php?id=2" rel="items">Link to product 2</a>
Run Code Online (Sandbox Code Playgroud)

这是我对Colorbox的调用:

$("a.items").colorbox({rel: 'items', iframe:true, transition:"fade", 
width:"80%", height:"90%", 
onClosed:function(){ location.reload(true); } });
Run Code Online (Sandbox Code Playgroud)

我读过这个, 但它对我不起作用,还有其他任何建议吗?

更新:我已经改变了一些事情,现在我正在使用以下调用在Colorbox中打开一个页面并显示一个特定的div.

$('a.items').colorbox({ href:function(){ return this.href + " #prodpreview"; }});
Run Code Online (Sandbox Code Playgroud)

但现在我已经失去了Colorbox的所有iframe功能,当我在彩盒中提交表单时,窗口关闭,我只剩下产品页面.那么我如何从这里开始组合这两个功能,打开Colorbox窗口以显示#div,同时还具有iframe功能,以便我可以在Colorbox中提交表单?

Sar*_*raz 8

如果要在colorbox中显示特定的div,您应该:

<div id="prodpreview" style="display:none">
   your stuff here
</div>
<a class='inline' href="#prodpreview">Inline HTML</a>

<script>
$(".inline").colorbox({inline:true});
</script>
Run Code Online (Sandbox Code Playgroud)