How to change website background when you hover on the block?

How to change background when you hover on the block?
Is it possible to implement in CSS or JS?

 <div class="block">Background 1</div>
 <div class="block">Background 2</div>
 <div class="block">Background 3</div>
 <div class="block">Background 4</div>
July 12th 19 at 16:52
2 answers
July 12th 19 at 16:54
Solution
and you can do whatever the unit does not display the picture but just text? - Roxanne commented on July 12th 19 at 16:57
: https://jsfiddle.net/x1j5f9z1/16/ - sandra.Daniel72 commented on July 12th 19 at 17:00
look did darken the background class as bg and make that dataval and block?
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
July 12th 19 at 16:56
For example:
$(".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