【发布时间】:2023-03-08 04:13:01
【问题描述】:
我有一系列使用 jQuery 链接的翻转图像。单击链接后,我希望将翻转图像的类别从“翻转”更改为“翻转2”,以便获得一组不同的图像。这是翻转图像的 jQuery:
$(document).ready(function() {
$("img.rollover").hover(
function() { this.src = this.src.replace("_off", "_on");
},
function() { this.src = this.src.replace("_on", "_off");
});
$("img.rollover2").hover(
function() { this.src = this.src.replace("_off2", "_on2");
},
function() { this.src = this.src.replace("_on2", "_off2");
});
});
这是链接图像的代码:
<a href="Mod1/index.html" target="_blank">
<img src="images/watch_off.png" class="rollover" />
</a>
初始翻转效果很好,但我试图使用来自here 的访问链接插件来触发将任何链接图像的类名更改为“翻转2”:
<script src="js/jquery.visited.js" type="text/javascript"></script>
<script type="text/javascript">
$('#links a').visited(function () {
// hides the li element
$(this).img.removeClass("rollover");
$(this).img.addClass("rollover2");
});
</script>
这似乎不起作用。你们中的任何人都可以帮助我解决这个问题吗?
【问题讨论】:
标签: jquery image class rollover visited