Javascript Jquery:Image-won';单击后不会更改,而是停留在悬停图像上。。
我想更改悬停时的图像,然后单击悬停图像时,我会将其更改为另一个图像。。 但是,问题是,当我单击onhover图像时,它将保留onhover图像,而不是将其更改为clicked图像 我的项目中有两个文件,分别是comp-profile.html和about.html,下面是源代码: comp-profile.html:Javascript Jquery:Image-won';单击后不会更改,而是停留在悬停图像上。。,javascript,jquery,html,image,load,Javascript,Jquery,Html,Image,Load,我想更改悬停时的图像,然后单击悬停图像时,我会将其更改为另一个图像。。 但是,问题是,当我单击onhover图像时,它将保留onhover图像,而不是将其更改为clicked图像 我的项目中有两个文件,分别是comp-profile.html和about.html,下面是源代码: comp-profile.html: $("#Content-header-wrapper #link1").unbind("hover").hover(function(){ alert("a
$("#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中时,它仍然会提醒“asd”
请帮我做这个^^
鼠标悬停
不是一个事件,因此无法解除绑定,您需要删除鼠标悬停
和鼠标悬停
事件
$("#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");
});
$("#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");
});