I have this jQuery script:
$('img[data-hover]').hover(function() {
$(this)
.attr('tmp', $(this).attr('src'))
.attr('src', $(this).attr('data-hover'))
.attr('data-hover', $(this).attr('tmp'))
.removeAttr('tmp');
}).each(function() {
$('<img />').attr('src', $(this).attr('data-hover'));
});
It works fine, when I hove the images, the hover works fine.
But now I need to start the hover again, when I click on certain boxes, on those:
$('#first, #second, #third').click(function(){ .....
Is it somehow possible to start the hover "on click" and keep the actual hover function? Or even modify it to a "function"?
I've tried it but I failed.
Thanks.
EDIT:
here's the HTML code with the images:
<div class="auswahlbox">
<div class="auswahl" id="first" data-id="1">
<div class="bild">
<img src="https://image.jpg" data-hover="https://images_hover.jpg" />
</div>
<div class="box">
<p>Text</p>
</div>
</div>
<div class="auswahl" id="second" data-id="2">
<div class="bild">
<img src="https://image.jpg" data-hover="https://images_hover.jpg" />
</div>
<div class="box">
<p>Text</p>
</div>
</div>
<div class="auswahl" id="third" data-id="3">
<div class="bild">
<img src="https://image.jpg" data-hover="https://images_hover.jpg" />
</div>
<div class="box">
<p>Text</p>
</div>
</div>
</div>
Situation now:
When I hove the images in .bild it works fine.
What I need:
When I click the "<div class="auswahl" id="first" data-id="1">" (second, third) div, the hover of the images shall "start" once.
#first, #second, #third" means you have also 3 images? Or you want to activate the "hover" on all your images?