Add jQuery colorbox plugin to a dynamically created element

前端 未结 6 1391
别跟我提以往
别跟我提以往 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:13

    I was having the same problem as @sunburst with having to click the trigger link twice. Used the same code, but .delegate() instead of .live(). Solved everything and cleaned up my jQuery nicely!

    Nice explanation here: http://www.alfajango.com/blog/the-difference-between-jquerys-bind-live-and-delegate/

提交回复
热议问题