To get my lightbox working, I am trying to set the data attribute "lightbox" on links that contain an image as a child. This doesn't seem to work too well. I have this fiddle.
var links = $(".single .entry-content a");
links.each(function () {
if ($(this).children("img").length > 0) {
$(this).data("lightbox","image-gallery");
console.log("test");
}
});
The console logs, but the data-attribute isn't set. What did I do wrong?