当用户将鼠标悬停在父 div 上时,我想用 jquery 淡入 div。
我有以下代码:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Explore D&D Creative</title>
<link rel="stylesheet" href="media/css/explore.css" />
<script type="text/javascript" src="media/js/jquery.min.js"></script>
<script type="text/javascript" src="media/js/jquery.custom.js"></script>
</head>
<body id="home">
<!-- BEGIN CONTENT -->
<div id="content">
<!-- BEGIN CONTENT TOP SLIDESHOW -->
<div id="top-slide">
<div class="wrapper">
</div>
<div id="select">...</div>
</div>
<!-- END CONTENT TOP SLIDESHOW -->
<!-- BEGIN CONTENT TWITTER -->
<div id="twitter-main">
<div class="wrapper">
<i class="icon-twitter"></i>
<span class="divider"></span>
<h2 class="feed">THIS IS SOME TWITTER TEXT</h2>
<p class="info">@DandDCreative - SOME TIME AGO</p>
</div>
</div>
<!-- END CONTENT TWIITER -->
</div>
<!-- END CONTENT -->
</body>
</html>
CSS:
/*============================================
CONTENT
============================================*/
#content {
min-height:100%;
margin-top:55px;
padding-top:10px;
}
/*============================================
HOME.PHP
============================================*/
#home #content #top-slide {
background-color:#3D3B37;
height:300px;
position:relative;
}
#home #content #top-slide #select {
height:48px;
width:100%;
position:absolute;
bottom:0;
background:url(../img/home/bg-slie-select.png) repeat;
display:none;
}
#home #content #twitter-main {
background-color:#cccccc;
height:200px;
margin:10px 0;
padding-top:30px;
text-align:center;
}
#home #content #twitter-main i.icon-twitter {
background:url(../img/common/social/twitter.png) no-repeat center;
width:37px;
height:37px;
margin:0px auto 20px auto;
display:block;
}
#home #content #twitter-main span.divider {
border-top:1px solid #535353;
height:0;
width:100px;
display:block;
margin:0 auto;
}
#home #content #twitter-main h2.feed {
margin:40px 0;
}
#home #content #twitter-main p.info {
font-size:10px;
color:#666666;
}
和JS:
$(document).ready(function() {
//HOME.PHP
$('#top-slide').mouseover(function() {
('#select').fadeIn(600);
});
$('#top-slide').mouseout(function() {
('#select').fadeOut(600);
});
});
此代码分别在鼠标移入和移出时出现以下错误:
Uncaught TypeError: Object #select has no method 'fadeIn'
Uncaught TypeError: Object #select has no method 'fadeOut'
我认为这可能与 mouseover / mouseout 方法有关,但也尝试使用 click 方法,但它也是如此。
我可能做了一些愚蠢的事情,但我找不到问题。
这是一个适合所有人的 JSFIDDLE:http: //jsfiddle.net/Ze28y/1/