Jquery div在单击时不显示
这个代码有什么问题?单击时不显示37DIVJquery div在单击时不显示,jquery,jquery-ui,Jquery,Jquery Ui,这个代码有什么问题?单击时不显示37DIV <a href="#" id="37" class="he"> CS504 </a> <script> $( "#37" ).click(function() { $( "37DIV" ).show( "bounce", 1000 ); }); </script> <div id="37DIV" style="display:none"> <a hr
<a href="#" id="37" class="he"> CS504 </a>
<script>
$( "#37" ).click(function() {
$( "37DIV" ).show( "bounce", 1000 );
});
</script>
<div id="37DIV" style="display:none">
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
您忘记了告诉jQuery按id搜索的命令 替换
$( "37DIV" ).
与
您还应该将代码放在就绪回调中
在使用jQuery之前,必须导入它。将导入元素放在文档的开头:
<!DOCTYPE html>
<html>
<head>
<title> no title </title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
</head>
<body>
<a href="#" id="37" class="he"> CS504 </a>
<div id="37DIV" style="display:none">
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
</div>
<script>
$(function(){
$("#37").click(function() {
$("#37DIV").show( "bounce", 1000 );
});
});
</script>
</body>
</html>
请注意,以数字开头的ID在HTML4中无效,但这应该不是问题。还要注意,jQuery1.5非常古老。您应该像使用最新的jQuery UI一样使用最新的版本。您忘记了告诉jQuery按id搜索的命令 替换
$( "37DIV" ).
与
您还应该将代码放在就绪回调中
在使用jQuery之前,必须导入它。将导入元素放在文档的开头:
<!DOCTYPE html>
<html>
<head>
<title> no title </title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
</head>
<body>
<a href="#" id="37" class="he"> CS504 </a>
<div id="37DIV" style="display:none">
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
</div>
<script>
$(function(){
$("#37").click(function() {
$("#37DIV").show( "bounce", 1000 );
});
});
</script>
</body>
</html>
请注意,以数字开头的ID在HTML4中无效,但这应该不是问题。还要注意,jQuery1.5非常古老。您应该像使用最新的jQuery UI一样使用最新的版本。您需要在选择器中的id之前,阅读有关选择器的更多信息
改变
$("37DIV" ).show( "bounce", 1000 );
到
在选择器中输入id之前,请阅读有关选择器的更多信息
改变
$("37DIV" ).show( "bounce", 1000 );
到
37美元。而不是37美元。在何处指定ID
$( "#37" ).click(function() {
$( "#37DIV" ).show( "bounce", 1000 );
});
37美元。而不是37美元。在何处指定ID
$( "#37" ).click(function() {
$( "#37DIV" ).show( "bounce", 1000 );
});
试试这个:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$( "#37" ).click(function() {
$( "#37DIV" ).show("bounce", 1000);
});
});
</script>
</head>
<body>
<a href="#" id="37" class="he"> CS504 </a>
<div id="37DIV" style="display:none">
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
</div>
</body>
</html>
试试这个:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$( "#37" ).click(function() {
$( "#37DIV" ).show("bounce", 1000);
});
});
</script>
</head>
<body>
<a href="#" id="37" class="he"> CS504 </a>
<div id="37DIV" style="display:none">
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
<a href="thread-52.html">lorem pum sum</a>
</div>
</body>
</html>
有关切换,请检查下面的
$( "#37" ).click(function() {
$( "#37DIV" ).toggle("bounce" );
});
有关切换,请检查下面的
$( "#37" ).click(function() {
$( "#37DIV" ).toggle("bounce" );
});
你错过了一场37美元的“反弹秀”,1000美元@NandakumarV仍然无法正常工作。按右键,您不应使用以开头的iddigit@user1479606确切地说,不以数字开头更好地符合HTML4,但旧浏览器是宽容的,但在HTML5中是不需要的@NandakumarV仍然无法正常工作。按右键,您不应使用以开头的iddigit@user1479606确切地说,不以数字开头更好地符合HTML4,但旧浏览器是宽容的,但在HTML5中不需要。完美如何使用toogle?我在下面添加了切换的答案请检查它完美如何使用toogle?我在下面添加了切换的答案请检查它完美我缺少正确的html,头标签,现在如何做这将toogle完美我错过了适当的html,头标签,现在如何做这将toogle