Add jQuery colorbox plugin to a dynamically created element

前端 未结 6 1390
别跟我提以往
别跟我提以往 2020-12-15 07:36

The usual way to assign color box functionality on a link is like this:

$(\"a.colorbox\").colorbox({ transition: \"elastic\" });

Newly added

6条回答
  •  攒了一身酷
    2020-12-15 08:23

    You could also try this:

    $('.colorbox').live('click',function(e){
        e.preventDefault();
        $(this).colorbox({open:true});
    });
    

    I think it's a little cleaner then using the fn command.

提交回复
热议问题