Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/479.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jquery:Image-won';单击后不会更改,而是停留在悬停图像上。。_Javascript_Jquery_Html_Image_Load - Fatal编程技术网

Javascript Jquery:Image-won';单击后不会更改,而是停留在悬停图像上。。

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

我想更改悬停时的图像,然后单击悬停图像时,我会将其更改为另一个图像。。 但是,问题是,当我单击onhover图像时,它将保留onhover图像,而不是将其更改为clicked图像

我的项目中有两个文件,分别是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中时,它仍然会提醒“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");
});