Javascript 任何URL的颜色框模式

Javascript 任何URL的颜色框模式,javascript,jquery,colorbox,Javascript,Jquery,Colorbox,我试图创建一个打开任何URL的模式,其中a标记有一个特定的类 在colorbox文档中,它以以下内容为例: // ColorBox can accept a function in place of a static value: $("a.gallery").colorbox({rel: 'gal', title: function(){ var url = $(this).attr('href'); return '<a href="' + url + '" target="_

我试图创建一个打开任何URL的模式,其中
a
标记有一个特定的类

在colorbox文档中,它以以下内容为例:

// ColorBox can accept a function in place of a static value:
$("a.gallery").colorbox({rel: 'gal', title: function(){
  var url = $(this).attr('href');
  return '<a href="' + url + '" target="_blank">Open In New Window</a>';
}});
//ColorBox可以接受函数代替静态值:
$(“a.gallery”).colorbox({rel:'gal',title:function(){
var url=$(this.attr('href');
返回“”;
}});
我的HTML结构是:

“class=“modal”rel=“gal”>


您正在对
元素使用
colorbox()
方法,这些元素不是该方法的有效元素。此方法只能用于
元素。

完全误解了该函数-如果您试图执行我在开场白中概述的操作,请使用iframe功能

e、 g


parent.$.colorbox.resize({width:460,height:130});

没有触发什么?是否执行属性
title
的函数?执行
colorbox()时DOM中是否存在类为“modal”的元素
method?也许我误解了函数的作用,但要回答您的问题:是的,模态存在,而title函数似乎没有启动。
        <h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>

        <div class="entry">
            <?php the_excerpt(); ?>
        </div>

</div>
jQuery(".modal").colorbox({rel: 'gal', title: function(){
  var url = jQuery(this).attr('href');
  return '<a href="' + url + '" target="_blank">Open In New Window</a>';
}});
jQuery(function () {
    jQuery(".modal").colorbox({iframe:true, innerWidth:425, innerHeight:344});    
})