Reputation: 343
I've got a complex dynamic image gallery, images loaded by php, layed out by jquery... and what I need to do, is use whatever image is loaded into the lightbox as the background for the containing div (in addition to displaying like normal)... I cant really add a class to the image itself, but I can target it via .lightbox img
any help is appreciated:
<div class="container">
<div class="lightbox">
<img src="image.jpg"><!--php dynamic loaded image-->
</div>
</div>
Upvotes: 0
Views: 367
Reputation: 4107
var $img = $('.lightbox img');
var $container = $('#main-container');
$container.css('background-image', 'url(' + $img.attr('src') + ')');
Upvotes: 3