如何获取花式框以定位页面上的特定DIV ID,而不是在fancybox中请求整个页面.
这个我的代码很好
这个我的代码很好
$(function() {
$(".style_image a").live('click',function(event) {
$(".style_image a").find("#show_style").fancybox();
});
});
这不行吗
我原来尝试了以下内容:
$(function() {
$(".style_image a").live('click',function(event) {
$(this.href + " #show_style").fancybox();
});
});
不知道怎么做,还是甚至可以呢?
here are the doc’s
解决方法
如果你想要fancybox打开某个div,你只需使用以下简单的步骤:
首先你需要一个链接来挂钩fancybox:
<a href="#myDivID" id="fancyboxLink">Click me to show this awesome div</a>
注意锚点旁边的div id.
第二,您需要一个将在fancybox内显示的div:
<!-- 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将它们整合在一起
<script type="text/javascript">
$("a#fancyboxLink").fancybox({
'href' : '#myDivID','titleShow' : false,'transitionIn' : 'elastic','transitionOut' : 'elastic'
});
</script>