反转功能或效果

reversing the function or effect

本文关键字:功能      更新时间:2023-09-26

我有下面的代码,我不知道如何反转函数。我想回到它开始的地方。第一张图片。谁能帮忙?

<div id="pin_point">
<img src="images/pin_point.png"  style="position:absolute;"/>
<img src="images/pin_point_black.png" style="position:absolute;display:none;"/>
</div>

 $(function() {
 $("#pin_point").hover(function() {
    $("#pin_point img").fadeToggle('medium');
});
 $("#pin_point").click(function() {
    $("#pin_point img").attr('src', 'images/ex.png');
});
 });

可以枚举这两个图像,然后将其.src和显示状态设置回起始状态。

var imgs = $("#pin_point img");
imgs.eq(0).attr("src", "images/pin_point.png").show();
imgs.eq(1).attr("src", "images/pin_point_black.png").hide();

如果要单击重置它,请将单击处理程序更改为:

$("#pin_point").click(function() {
    var imgs = $("#pin_point img");
    imgs.eq(0).attr("src", "images/pin_point.png").show();
    imgs.eq(1).attr("src", "images/pin_point_black.png").hide();
});