我正在尝试创建一个打开任何 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>';
}});
我的 HTML 结构是:
" 类="模态" rel="gal">
<h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>
<div class="entry">
<?php the_excerpt(); ?>
</div>
</div>
我的JS是:
jQuery(".modal").colorbox({rel: 'gal', title: function(){
var url = jQuery(this).attr('href');
return '<a href="' + url + '" target="_blank">Open In New Window</a>';
}});
但这只是没有触发 - 我没有收到任何控制台 JS 错误 - 任何人都可以看到这里有什么问题吗?