如何用javascript onClick事件而不是链接调用jQuery colorbox?
问题描述:
答
这是我的头顶。但我相信你可以做这样的事情:
<script type="text/javascript">
function call_cbox()
{
jQuery.colorbox({html:'<p>Hi There I was instantiated onclick!</p>'});
}
</script>
<a href="#" onclick="call_cbox(); return false;">Give me a colorbox... NOW! And don't forget the color.</a>
答
前面的例子并没有为我工作,但使用相同的想法,这样做的工作:
<script>
function lightbox(){
$.colorbox({width:"80%", height:"80%", iframe:true, href:"/pagetoopen.html"});
}
</script>
<input type="button" value="open the box" onClick="lightbox()"/>
答
两个答案的混合上述工作对我来说:
<script>
function call_cbox()
{
jQuery().colorbox({width:"900px", height:"600px", iframe:true, href:"/newsletter.html"});
}
</script>
答
$("tr").click(function() {
$.colorbox({width:"900px", height:"600px", iframe:true, href:"http://www.google.com"});
});
看来,这不是为我工作了。我不知道它是来自Colorbox更新还是jQuery更新。 – Keith 2013-02-19 20:31:56