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.
});
精彩评论