Jquery:图像获胜'点击后不会改变,而是停留在悬停图像上.
Jquery: Image won't change after being clicked, instead it stays at hover image..
我想在悬停时更改我的图像,然后当我单击悬停的图像时,我会将其更改为另一个图像。。但是,问题是,当我单击onhover图像时,它将保留在onhoverimage中,而不是将其更改为单击的图像。。
我的项目中有两个文件comp-profile.html和about.html,下面是源代码:
comp-profile.html:
$("#Content-header-wrapper #link1").unbind("hover").hover(function(){
alert("asd");
$("#Content-header-wrapper #link1").attr("src","Images/Content/link-about-hover.png");
},function(){
$("#Content-header-wrapper #link1").attr("src","Images/Content/link-about.png");
});
$("#Content-header-wrapper #link1").unbind("click").click(function(){
$("#Content-header-wrapper #link1").attr("src","Images/Content/link-comp-profile.png");
$("#Content-header-wrapper #link2").attr("src","Images/Content/link-contact.png");
$("#Content-header-wrapper #link1").attr("alt","link-comp-profile");
$("#Content-header-wrapper #link2").attr("alt","link-contact");
$("#Content-header").html("<img src='Images/Content/header-about.png' alt='header-about' width='273px' height='41'/>");
$("#Content-fill").empty();
$("#Content-fill").load("about-content.html");
$("#Content").fadeOut(0);
$("#Content").animate({opacity: 'toggle', height: 'toggle'},"slow");
});
about.html:
$("#Content-header-wrapper #link1").unbind("hover").hover(function(){
$("#Content-header-wrapper #link1").attr("src","Images/Content/link-comp-profile-hover.png");
},function(){
$("#Content-header-wrapper #link1").attr("src","Images/Content/link-comp-profile.png");
});
另一个奇怪的想法是,每当我将图像悬停在about.html中时,它仍然会提醒"asd"。。。
请帮我做这件事。^^
hover
不是事件,因此无法解除绑定,需要删除mouseenter
和mouseleave
事件。
$("#Content-header-wrapper #link1").off("mouseenter mouseleave").hover(function () {
$("#Content-header-wrapper #link1").attr("src", "Images/Content/link-comp-profile-hover.png");
}, function () {
$("#Content-header-wrapper #link1").attr("src", "Images/Content/link-comp-profile.png");
});
相关文章:
- jQuery:当屏幕大小改变时,如何更改默认图像和悬停图像
- flexislider无法在现场工作,图像没有旋转,但导航点正在改变
- 谷歌地球Api改变图像对比度
- 为什么我的图像高度没有改变
- nodejs改变图像质量
- Jquery:图像获胜'点击后不会改变,而是停留在悬停图像上.
- JavaScript骰子游戏 - 图像不会改变
- JavaScript,用动画改变图像
- 为什么可以't改变图像's src属性
- 根据所述选择框的值来改变所述图像大小
- 不断改变图像的色调
- Alining 2背景图像,改变窗口大小(背景大小:封面)
- 背景图像是't改变
- 改变“;背景图像:“;在计时器上使用javascript无法工作
- 在缩略图上更改滑块图像.图像改变一秒钟,然后恢复
- 侧滚动图像,但图像改变
- 如何设置一个图像改变源基于两个不同的单选按钮
- CSS背景图像改变与javascript翻转innerhtml
- DIV背景图像改变,但有限制:没有JavaScript "标签"
- 如何有不同的图像改变每秒钟在一个Div