我试图让顶部div在点击时淡出,但我无法让它工作。这是我的代码:
<script type = 'text/javascript' src = '../Javascript/jquery/jquery-1.6.2.js'></script>
<script type = 'text/javascript'>
$(document).ready(function() {
$('#topcontent').click (
function() {
$('#topcontent').fadeTo(300,0.0);
}
);
}
</script>
</head>
<body>
<div id = 'wrapper'>
<div id = 'topcontent'>
TOP<br />
</div>
<div id = 'bottomcontent'>
BOTTOM
</div>
<div id = 'sub'>
This site is still being created. Check back soon!
</div>
</div>
</body>
关于它为什么不起作用的任何想法?
答案 0 :(得分:6)
您忘记了$(document).ready(function(){});
末尾的右括号。
答案 1 :(得分:1)
您只有语法错误
$(document).ready(function() {
$('#topcontent').click (
function() {
$('#topcontent').fadeTo(300,0.0);
});
});