Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用javascript onClick事件而不是链接调用jQuery colorbox?_Javascript_Jquery_Colorbox - Fatal编程技术网

如何使用javascript onClick事件而不是链接调用jQuery colorbox?

如何使用javascript onClick事件而不是链接调用jQuery colorbox?,javascript,jquery,colorbox,Javascript,Jquery,Colorbox,我想使用javascript而不是href链接调用colorbox 有人知道我怎么做吗 谢谢。这是我不知道的。但我相信你可以这样做: <script type="text/javascript"> function call_cbox() { jQuery.colorbox({html:'<p>Hi There I was instantiated onclick!</p>'}); } </script> <a href="#" onc

我想使用javascript而不是href链接调用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>

函数调用_cbox()
{
colorbox({html:'Hi,我在这里被实例化了onclick!

'}); }
前面的示例对我不起作用,但使用相同的想法,这确实有效:

<script>
function lightbox(){    
  $.colorbox({width:"80%", height:"80%", iframe:true, href:"/pagetoopen.html"});
}
</script>

<input type="button" value="open the box" onClick="lightbox()"/>

函数lightbox(){
$.colorbox({宽度:“80%”,高度:“80%”,iframe:true,href:“/pagetoopen.html”});
}

以上两个答案的组合对我来说很有用:

<script>
function call_cbox()
{
jQuery().colorbox({width:"900px", height:"600px", iframe:true, href:"/newsletter.html"});
}
</script>

函数调用_cbox()
{
jQuery().colorbox({宽度:“900px”,高度:“600px”,iframe:true,href:“/newsletter.html”});
}

这似乎不再适用于我了。我不知道它是来自Colorbox更新还是jquery更新。
$("tr").click(function () { 

    $.colorbox({width:"900px", height:"600px", iframe:true, href:"http://www.google.com"});

});