S
S
sokol11112020-04-27 14:29:34
JavaScript
sokol1111, 2020-04-27 14:29:34

How to set the block background by clicking on the image?

Good day. There is a block with pictures (.img-container) that are output from the server.
How to make it so that when you click on an image, the src of this image is taken and transferred to the background of the block (.bg-box)?
Here is an example: u0763918test1.isp.regruhosting.ru

<div class="img-container">
    <?php
    include('gallery.php');
    ?>
</div>

<div class="bg-box">

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Sobolev, 2020-04-27
@san_jorich

jQuery change the css property of the block
jQuery('#your_button_id').on('click',function(){ jQuery(desired_div).css('background_image','url'); ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question