使用colorbox jquery插件加载部分(外部)html页面 [英] Loading a partial (external) html page using colorbox jquery plugin
问题描述
我如何才能在链接的html页面中仅使用包含div的内容?加载完整页面就可以了.但是,我只希望加载页面的子div.
How do i get it to use only a containing div inside a linked html page.? Loading complete page is fine. However i wish to load only a child div of the loaded page.
html
<a href="/OrchardLocal/FactFindPreview?id=5" class="cboxElement">View Fact Submission</a>
jquery(在文档上可用)
jquery (on doc ready)
$(".required-info a").colorbox({ iframe: true, width: "80%", height: "80%" });
推荐答案
ColorBox的ajax功能由jQuery的load()方法处理,因此其工作方式相同.传递给colorbox的URL必须后缀一个空格,然后是要显示的内容的选择器.例如:$.colorbox({href: "mypage.html #myselector"});
ColorBox's ajax functionality is handled by jQuery's load() method, so it works the same way. The URL you pass to colorbox with have to be suffixed with a space, then a selector for the content you want to display. For example: $.colorbox({href: "mypage.html #myselector"});
您的用法如下所示:
$(".required-info a").colorbox({ href: function(){ return $(this).attr('href') + ' #mycontainer'; }, width: "80%", height: "80%" });
这篇关于使用colorbox jquery插件加载部分(外部)html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!