Home > Article > Web Front-end > jquery pop-up plug-in colorbox binding method to dynamically generate elements_jquery
Colorbox is a very easy-to-use pop-up plug-in for jquery. It has rich functions and a good user experience.
colorbox official website: http://www.jacklmoore.com/colorbox/
I just encountered a problem when using colorbox, which I had not noticed before.
I used to talk about using this plug-in in static HTML elements, but today I found that it cannot be used when binding dynamically generated elements.
The conventional usage is as follows:
The above method only applies to static elements. If you want to bind colorbox effects to dynamic elements, you have to use the following method:
We assume that the tag in the above HTML is a dynamically generated element, then the js has to be written like this:
Okay, the problem is solved perfectly. Hope it helps.