jQuery FancyBox目标特定的DIV ID? [英] Jquery FancyBox target specific DIV ID?
本文介绍了jQuery FancyBox目标特定的DIV ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取花式"框以将页面上的特定DIV ID定位为目标,而不是在花式"框中请求整个页面. 这是我的代码如此
How do I get Fancy box to target a specific DIV ID on a page and not request the whole page in the fancybox.? This my code so fare
$(function() {
$(".style_image a").live('click', function(event) {
$(".style_image a").find("#show_style").fancybox();
});
});
这行不通吗?
我最初尝试了以下方法:
I originally tried the following:
$(function() {
$(".style_image a").live('click', function(event) {
$(this.href + " #show_style").fancybox();
});
});
不确定如何做到,或者是否有可能?
Not sure how this done, or if it is even possible?
推荐答案
如果您想让fancybox打开某个div,只需使用以下简单步骤:
If you want fancybox to open a certain div you just use the following simple steps:
首先,您需要一个链接来将FancyBox挂钩到:
First you need a link to hook FancyBox to:
<a href="#myDivID" id="fancyBoxLink">Click me to show this awesome div</a>
请注意锚点旁边的 div ID .
第二步,您需要在FancyBox内显示一个div:
Second you need a div that will be shown inside the FancyBox:
<!-- Wrap it inside a hidden div so it won't show on load -->
<div style="display:none">
<div id="myDivID">
<span>Hey this is what is shown inside fancybox.</span>
<span>Apparently I can show all kinds of stuff here!</span>
<img src="../images/unicorn.png" alt="" />
<input type="text" value="Add some text here" />
</div>
</div>
第三个非常简单的javascript将它们钩在一起
And third some very easy javascript to hook it all together
<script type="text/javascript">
$("a#fancyBoxLink").fancybox({
'href' : '#myDivID',
'titleShow' : false,
'transitionIn' : 'elastic',
'transitionOut' : 'elastic'
});
</script>
这篇关于jQuery FancyBox目标特定的DIV ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文