Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.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 在鼠标上方交换图像_Javascript_Jquery_Html_Css_Image - Fatal编程技术网

Javascript 在鼠标上方交换图像

Javascript 在鼠标上方交换图像,javascript,jquery,html,css,image,Javascript,Jquery,Html,Css,Image,我在页面顶部有一个链接图像,下面有5个链接图像。当鼠标移到下面的图片上时,上面的图片应该变成鼠标移过的图片和鼠标移过的链接,它的大小也应该是图片的两倍,但我甚至不能让它改变图片/链接 这是我的jQuery代码: $(document).ready(function() { $("google").mouseenter(function() { $("big").attr({ "href": "http://i.imgur.com/oO1RrsF.png?1",

我在页面顶部有一个链接图像,下面有5个链接图像。当鼠标移到下面的图片上时,上面的图片应该变成鼠标移过的图片和鼠标移过的链接,它的大小也应该是图片的两倍,但我甚至不能让它改变图片/链接

这是我的jQuery代码:

$(document).ready(function() {
$("google").mouseenter(function() {
        $("big").attr({
        "href": "http://i.imgur.com/oO1RrsF.png?1",
        "src": "http://www.google.com".
    });
});
$("apple").mouseenter(function() {
        $("big").attr({ 
        "href" : "http://www.apple.com",
        "src" : "http://i.imgur.com/eHm7Nbg.png?1"
    });
});

$("facebook").mouseenter(function() {
        $("big").attr({
        "href" : "http://www.facebook.com",
        "src" : "http://i.imgur.com/ovkudjR.png?2"
    });
});

$("hooli").mouseenter(function() {
        $("big").attr({
        "href" : "http://www.hooli.xyz",
        "src" : "http://i.imgur.com/yfEYkoZ.png?2"
    });
});

$("piedpiper").mouseenter(function() {
        $("big").attr({
        "href" : "http://www.piedpiper.com",
        "src" : "http://i.imgur.com/Q3IhTeK.jpg?1"
    });
});
});

big
是顶部图像的id。我将id标签放在围绕img标签的
中。我已经玩了一段时间了,什么都没用。任何帮助都将不胜感激

您的选择器错误。您需要以下任一项

$("#google"); //ID google
$(".google"); //Class google

所有其他选择器也是如此。

您的选择器是错误的。您需要以下任一项

$("#google"); //ID google
$(".google"); //Class google

所有其他选择器也是如此。

您的选择器是错误的。您需要以下任一项

$("#google"); //ID google
$(".google"); //Class google

所有其他选择器也是如此。

您的选择器是错误的。您需要以下任一项

$("#google"); //ID google
$(".google"); //Class google
对于所有其他选择器也是如此。

使用#选择ID和。用于选择类以访问元素。 然后在mousemove上更改所选元素的来源,就像您所做的那样。

使用#选择ID和。用于选择类以访问元素。 然后在mousemove上更改所选元素的来源,就像您所做的那样。

使用#选择ID和。用于选择类以访问元素。 然后在mousemove上更改所选元素的来源,就像您所做的那样。

使用#选择ID和。用于选择类以访问元素。 然后在mousemove上更改所选元素的源,就像您所做的那样。

Demo

HTML

 <a href="" id="big_a"><img src="" href="" id="big" /></a>
脚本

 var lists = {
     "google": {
         href: "http://www.google.com",
         src: "http://i.imgur.com/oO1RrsF.png?1"
     },
         "apple": {
         href: "http://i.imgur.com/oO1RrsF.png?1",
         src: "http://i.imgur.com/eHm7Nbg.png?1"
     },
         "facebook": {
         href: "http://www.facebook.com",
         src: "http://i.imgur.com/ovkudjR.png?2"
     },
         "hooli": {
         href: "http://www.hooli.xyz",
         src: "http://i.imgur.com/yfEYkoZ.png?2"
     },
         "piedpiper": {
         href: "http://www.piedpiper.com",
         src: "http://i.imgur.com/Q3IhTeK.jpg?1"
     }

 }

 $.each(lists, function (i, e) {
     $("<a target='_blank' id='anc_" + i + "' href='" + e.href + "'><img class='small' src='" + e.src + "' id='" + i + "' alt='" + i + "'/></a><br>").appendTo("body");
     $("#" + i).mouseenter(function () {
         $("#big").attr("src", $(this).attr("src"));
         $("#big_a").attr("href", $("#anc_" + $(this).attr("id")).attr("href"));
     });
 });
var列表={
“谷歌”:{
href:“http://www.google.com",
src:“http://i.imgur.com/oO1RrsF.png?1"
},
“苹果”:{
href:“http://i.imgur.com/oO1RrsF.png?1",
src:“http://i.imgur.com/eHm7Nbg.png?1"
},
“facebook”:{
href:“http://www.facebook.com",
src:“http://i.imgur.com/ovkudjR.png?2"
},
“胡里”:{
href:“http://www.hooli.xyz",
src:“http://i.imgur.com/yfEYkoZ.png?2"
},
“piedpiper”:{
href:“http://www.piedpiper.com",
src:“http://i.imgur.com/Q3IhTeK.jpg?1"
}
}
$。每个(列表、函数(即){
$(“
”)。附录(“正文”); $(“#”+i).mouseenter(函数(){ $(“#big”).attr(“src”),$(this.attr(“src”)); $(“#big_a”).attr(“href”),$(“#anc_u”+$(this.attr(“id”).attr(“href”); }); });
演示

HTML

 <a href="" id="big_a"><img src="" href="" id="big" /></a>
脚本

 var lists = {
     "google": {
         href: "http://www.google.com",
         src: "http://i.imgur.com/oO1RrsF.png?1"
     },
         "apple": {
         href: "http://i.imgur.com/oO1RrsF.png?1",
         src: "http://i.imgur.com/eHm7Nbg.png?1"
     },
         "facebook": {
         href: "http://www.facebook.com",
         src: "http://i.imgur.com/ovkudjR.png?2"
     },
         "hooli": {
         href: "http://www.hooli.xyz",
         src: "http://i.imgur.com/yfEYkoZ.png?2"
     },
         "piedpiper": {
         href: "http://www.piedpiper.com",
         src: "http://i.imgur.com/Q3IhTeK.jpg?1"
     }

 }

 $.each(lists, function (i, e) {
     $("<a target='_blank' id='anc_" + i + "' href='" + e.href + "'><img class='small' src='" + e.src + "' id='" + i + "' alt='" + i + "'/></a><br>").appendTo("body");
     $("#" + i).mouseenter(function () {
         $("#big").attr("src", $(this).attr("src"));
         $("#big_a").attr("href", $("#anc_" + $(this).attr("id")).attr("href"));
     });
 });
var列表={
“谷歌”:{
href:“http://www.google.com",
src:“http://i.imgur.com/oO1RrsF.png?1"
},
“苹果”:{
href:“http://i.imgur.com/oO1RrsF.png?1",
src:“http://i.imgur.com/eHm7Nbg.png?1"
},
“facebook”:{
href:“http://www.facebook.com",
src:“http://i.imgur.com/ovkudjR.png?2"
},
“胡里”:{
href:“http://www.hooli.xyz",
src:“http://i.imgur.com/yfEYkoZ.png?2"
},
“piedpiper”:{
href:“http://www.piedpiper.com",
src:“http://i.imgur.com/Q3IhTeK.jpg?1"
}
}
$。每个(列表、函数(即){
$(“
”)。附录(“正文”); $(“#”+i).mouseenter(函数(){ $(“#big”).attr(“src”),$(this.attr(“src”)); $(“#big_a”).attr(“href”),$(“#anc_u”+$(this.attr(“id”).attr(“href”); }); });
演示

HTML

 <a href="" id="big_a"><img src="" href="" id="big" /></a>
脚本

 var lists = {
     "google": {
         href: "http://www.google.com",
         src: "http://i.imgur.com/oO1RrsF.png?1"
     },
         "apple": {
         href: "http://i.imgur.com/oO1RrsF.png?1",
         src: "http://i.imgur.com/eHm7Nbg.png?1"
     },
         "facebook": {
         href: "http://www.facebook.com",
         src: "http://i.imgur.com/ovkudjR.png?2"
     },
         "hooli": {
         href: "http://www.hooli.xyz",
         src: "http://i.imgur.com/yfEYkoZ.png?2"
     },
         "piedpiper": {
         href: "http://www.piedpiper.com",
         src: "http://i.imgur.com/Q3IhTeK.jpg?1"
     }

 }

 $.each(lists, function (i, e) {
     $("<a target='_blank' id='anc_" + i + "' href='" + e.href + "'><img class='small' src='" + e.src + "' id='" + i + "' alt='" + i + "'/></a><br>").appendTo("body");
     $("#" + i).mouseenter(function () {
         $("#big").attr("src", $(this).attr("src"));
         $("#big_a").attr("href", $("#anc_" + $(this).attr("id")).attr("href"));
     });
 });
var列表={
“谷歌”:{
href:“http://www.google.com",
src:“http://i.imgur.com/oO1RrsF.png?1"
},
“苹果”:{
href:“http://i.imgur.com/oO1RrsF.png?1",
src:“http://i.imgur.com/eHm7Nbg.png?1"
},
“facebook”:{
href:“http://www.facebook.com",
src:“http://i.imgur.com/ovkudjR.png?2"
},
“胡里”:{
href:“http://www.hooli.xyz",
src:“http://i.imgur.com/yfEYkoZ.png?2"
},
“piedpiper”:{
href:“http://www.piedpiper.com",
src:“http://i.imgur.com/Q3IhTeK.jpg?1"
}
}
$。每个(列表、函数(即){
$(“
”)。附录(“正文”); $(“#”+i).mouseenter(函数(){ $(“#big”).attr(“src”),$(this.attr(“src”)); $(“#big_a”).attr(“href”),$(“#anc_u”+$(this.attr(“id”).attr(“href”); }); });
演示

HTML

 <a href="" id="big_a"><img src="" href="" id="big" /></a>
脚本

 var lists = {
     "google": {
         href: "http://www.google.com",
         src: "http://i.imgur.com/oO1RrsF.png?1"
     },
         "apple": {
         href: "http://i.imgur.com/oO1RrsF.png?1",
         src: "http://i.imgur.com/eHm7Nbg.png?1"
     },
         "facebook": {
         href: "http://www.facebook.com",
         src: "http://i.imgur.com/ovkudjR.png?2"
     },
         "hooli": {
         href: "http://www.hooli.xyz",
         src: "http://i.imgur.com/yfEYkoZ.png?2"
     },
         "piedpiper": {
         href: "http://www.piedpiper.com",
         src: "http://i.imgur.com/Q3IhTeK.jpg?1"
     }

 }

 $.each(lists, function (i, e) {
     $("<a target='_blank' id='anc_" + i + "' href='" + e.href + "'><img class='small' src='" + e.src + "' id='" + i + "' alt='" + i + "'/></a><br>").appendTo("body");
     $("#" + i).mouseenter(function () {
         $("#big").attr("src", $(this).attr("src"));
         $("#big_a").attr("href", $("#anc_" + $(this).attr("id")).attr("href"));
     });
 });
var列表={
“谷歌”:{
href:“http://www.google.com",
src:“http://i.imgur.com/oO1RrsF.png?1"
},
“苹果”:{
href:“http://i.imgur.com/oO1RrsF.png?1",
src:“http://i.imgur.com/eHm7Nbg.png?1"
},
“facebook”:{
href:“http://www.facebook.com",
src:“http://i.imgur.com/ovkudjR.png?2"
},
“胡里”:{
href:“http://www.hooli.xyz",
src:“http://i.imgur.com/yfEYkoZ.png?2"
},
“piedpiper”:{
href:“http://www.piedpiper.com",
src:“http://i.imgur.com/Q3IhTeK.jpg?1"
}
}
$。每个(列表、函数(即){
$(“
”)。附录(“正文”); $(“#”+i).mouseenter(函数(){ $(“#big”).attr(“src”),$(this.attr(“src”)); $(“#big_a”).attr(“href”),$(“#anc_u”+$(this.attr(“id”).attr(“href”); }); });