gpt4 book ai didi

jquery - Colorbox - 如何仅显示特定的 DIV

转载 作者:行者123 更新时间:2023-12-01 06:37:26 25 4
gpt4 key购买 nike

我正在使用 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>

这是我对 Colorbox 的调用:

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

我已阅读 this但它对我不起作用,还有其他建议吗?

更新:我更改了一些内容,现在我使用以下调用在 Colorbox 中打开页面并显示特定的 div。

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

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

最佳答案

如果你想在 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>

关于jquery - Colorbox - 如何仅显示特定的 DIV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10994706/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com