<div class="block">Background 1</div>
<div class="block">Background 2</div>
<div class="block">Background 3</div>
<div class="block">Background 4</div>
$(".block").hover(
function() {
$img = $(this).text(); // takes the BACKGROUND (if you have it directly link)
// if not a link and for example the img: $img = $(this).find('img').attr('src');
$('.bg').css('background-image', 'url(' + $img + ')');
}, function() {}
);
Find more questions by tags JavaScriptCSS
background: linear-gradient( rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.75)), url(img.jpg) no-repeat; - Roxanne commented on July 12th 19 at 17:03