2016-04-04 27 views
0

我正在尝试制作网页的按钮,您可以将鼠标悬停在上面,并在其旁边会显示链接和信息。网页Jquery下拉按钮不起作用

下面是什么样子的链接:https://jsfiddle.net/kvbvLy4d/

落实到网页我有按钮停止工作之后。这是我有:

(我已删除了不相关的代码,以尽量减少长 - 让我知道如果你需要我发布完整的脚本)

HTML

<html> 
<head> 
    <link rel="stylesheet" type="text/css" href="layout.css"> 
    <script src="resources/scripts/jquery-1.12.2.min.js"></script> 
    <script src="resources/scripts/jquery.cycle.all.js"></script> 

</head> 
<body> 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> 
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> 
<script type="text/javascript"> 
$("#box, #content").on("mouseenter", function() { 
    $("#content").slideDown(); //.show(); 
}) 
.on("mouseleave", function() { 
    if (!$("#content").is(":hover")) 
    $("#content").fadeOut(); //hide(); 
}); 

$("#box1, #content1").on("mouseenter", function() { 
    $("#content1").slideDown(); //.show(); 
}) 
.on("mouseleave", function() { 
    if (!$("#content1").is(":hover")) 
    $("#content1").fadeOut(); //hide(); 
}); 

$("#box2, #content2").on("mouseenter", function() { 
    $("#content2").slideDown(); //.show(); 
}) 
.on("mouseleave", function() { 
    if (!$("#content2").is(":hover")) 
    $("#content2").fadeOut(); //hide(); 
}); 
</script> 

<div id="buttons"> 
    <div id="box"></div> 
    <div id="content">content here</div> 
    <div id="box1"></div> 
    <div id="content1">content here</div> 
    <div id="box2"></div> 
    <div id="content2">content here</div> 
</div> 
</div> 
</body> 
</html> 

CSS

(对于每个盒子和内容div除了位置相同)

#box { 
    position: absolute; 
    top: 23vw; 
    width: 10vw; 
    height: 10vw; 
    background-color: blue; 
} 

#content { 
    position: absolute; 
    top: 23vw; 
    left: 11vw; 
    width: 10vw; 
    height: 10vw; 
    background-color: red; 
    display: none; 
} 

任何帮助,更好的方法来做到这一点或特定回答这个问题的链接将非常感激。谢谢!

+0

你的小提琴作品对我来说你的jQuery函数。 –

+0

对不起,可能不是很清楚:p小提琴不是问题,当我尝试将它应用于我的网页时。我发布的代码来自我的页面。 –

+0

尝试评论某些资产。这一个特别是'' –

回答

0

<html> 
 
<head> 
 
    <link rel="stylesheet" type="text/css" href="layout.css"> 
 
    <script src="resources/scripts/jquery-1.12.2.min.js"></script> 
 
    <script src="resources/scripts/jquery.cycle.all.js"></script> 
 

 
</head> 
 
<body> 
 

 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> 
 
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> 
 
<script type="text/javascript"> 
 
    $(document).ready(function() { 
 
$("#box, #content").on("mouseenter", function() { 
 
    $("#content").slideDown(); //.show(); 
 
}) 
 
.on("mouseleave", function() { 
 
    if (!$("#content").is(":hover")) 
 
    $("#content").fadeOut(); //hide(); 
 
}); 
 

 
$("#box1, #content1").on("mouseenter", function() { 
 
    $("#content1").slideDown(); //.show(); 
 
}) 
 
.on("mouseleave", function() { 
 
    if (!$("#content1").is(":hover")) 
 
    $("#content1").fadeOut(); //hide(); 
 
}); 
 

 
$("#box2, #content2").on("mouseenter", function() { 
 
    $("#content2").slideDown(); //.show(); 
 
}) 
 
.on("mouseleave", function() { 
 
    if (!$("#content2").is(":hover")) 
 
    $("#content2").fadeOut(); //hide(); 
 
}); 
 
    }); 
 
</script> 
 

 
<div id="buttons"> 
 
    <div id="box"></div> 
 
    <div id="content">content here</div> 
 
    <div id="box1"></div> 
 
    <div id="content1">content here</div> 
 
    <div id="box2"></div> 
 
    <div id="content2">content here</div> 
 
</div> 
 
</div> 
 
</body> 
 
</html>

里面添加document.ready