$('> .child-class', this); $('.element', this); $('.thisParent').each(function() { var imageUrl = $(this).find('img').attr('src'); //console.log(imageUrl); $('> .vc_column-inner', this).css("background-image", "url(" + imageUrl + ")"); $(this).find('img').addClass('hidden'); });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter