【问题标题】:How to call jQuery colorbox with javascript onClick event instead of a link?如何使用 javascript onClick 事件而不是链接调用 jQuery 颜色框?
【发布时间】:2010-12-10 04:32:28
【问题描述】:

我想使用 javascript 而不是 href 链接调用颜色框?

有人知道我该怎么做吗?

谢谢。

【问题讨论】:

    标签: javascript jquery colorbox


    【解决方案1】:

    前面的例子对我不起作用,但使用相同的想法,这确实有效:

    <script>
    function lightbox(){    
      $.colorbox({width:"80%", height:"80%", iframe:true, href:"/pagetoopen.html"});
    }
    </script>
    
    <input type="button" value="open the box" onClick="lightbox()"/>
    

    【讨论】:

      【解决方案2】:

      这不是我的想法。但我相信你可以这样做:

      <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>
      

      【讨论】:

        【解决方案3】:

        以上两个答案的混合对我有用:

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

        【讨论】:

        • 这似乎不再适合我了。我不知道它是来自 Colorbox 更新还是 jquery 更新。
        【解决方案4】:
        $("tr").click(function () { 
        
            $.colorbox({width:"900px", height:"600px", iframe:true, href:"http://www.google.com"});
        
        });
        

        【讨论】:

          猜你喜欢
          • 2023-03-21
          • 1970-01-01
          • 1970-01-01
          • 2013-02-09
          • 1970-01-01
          • 1970-01-01
          • 2011-07-05
          • 2013-02-19
          • 1970-01-01
          相关资源
          最近更新 更多