如何获取花式框以定位页面上的特定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();
- });
- });
不知道怎么做,还是甚至可以呢?
解决方法
如果你想要fancybox打开某个div,你只需使用以下简单的步骤:
- <a href="#myDivID" id="fancyboxLink">Click me to show this awesome div</a>
注意锚点旁边的div id.
- <!-- 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将它们整合在一起