开发者

How do I get a jQuery ColorBox window to open when clicking a checkbox?

开发者_运维知识库

I'm trying to get a jQuery ColorBox window to open when a checkbox is checked and I'm having some issues figuring it out. First of all, can it be done with out making major changes to the colorbox.js file? If so, can you help steer me in the right direction on how to go about this?

Thanks in advance.


Try this (demo)

HTML

<input type="checkbox" value="http://s3.tinypic.com/546ut2_th.jpg" title="image"> Image

Script

$(':checkbox').bind('click', function() {
    if ($(this).is(':checked')) {
        $.colorbox({
            photo: true,
            href: $(this).val()
        });
    }
})


I'm not exactly sure what you are trying to do, but with the information you've given, could you not bind the focus event on the checkbox to a function that opens an instance of ColorBox?

$("selectorForCheckbox").bind("focus", function(e) {
    // initiate colorbox here. 
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜