Javascript JQuery-单击并将鼠标悬停在同一函数上

Javascript JQuery-单击并将鼠标悬停在同一函数上,javascript,jquery,function,jquery-hover,Javascript,Jquery,Function,Jquery Hover,我有这个jQuery脚本: $('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

我有这个jQuery脚本:

$('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'));

});  
是否有可能在单击时启动悬停并保持实际的悬停功能?甚至将其修改为“函数”

我试过了,但失败了。
谢谢

编辑:
以下是带有图像的HTML代码:

<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>    

正文

正文

正文

现在的情况:
当我把图片放进去的时候,效果很好

我需要什么:

当我单击
(第二、第三)div时,图像的悬停将“开始”一次。

您的意思是这样的:

$('#first, #second, #third').click(function(){
    $('img[data-hover]').trigger('mouseover');
});
当单击
#第一、第二、第三
时,它会在
img[data hover]
上触发悬停事件

要仅在相同的
div中触发图像,请尝试:

$('#first, #second, #third').click(function(){
    $(this).find('img[data-hover]').trigger('mouseover');
});

#第一、#第二、#第三
”表示您还有3张图像?或者你想在你所有的图片上激活“悬停”,如果没有html代码,你的问题就不清楚了。这很好。像这样的。但我忘了提到的是,我需要在函数之前的相同图像上启动悬停。我在几分钟内添加了代码。是的,悬停本身可以工作,但触发器不能。我得到了另一个在那些盒子里工作的函数。是的,它是有效的。。。确实很好,但是所有的照片都是这样。是否可以只触发同一“div”中的图片?我刚刚添加了一个
click
事件的变体,该事件将只针对单击的div中的图像。
$('#first, #second, #third').click(function(){
    $(this).find('img[data-hover]').trigger('mouseover');
});