What am I doing wrong in the following example? The jquery code needs to go above the footer div in this case.
我在下面的例子中做错了什么?在这种情况下,jquery代码需要超过页脚div。
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
</head>
<body>
<script>
#(document).ready(function(){
$('#footer').hide();
});
</script>
<div id="footer">testing footer</div>
</body>
</html>
2 个解决方案
#1
11
Typo:
错字:
#(document).ready(function(){
Should be:
应该:
$(document).ready(function(){
You should see some sort of Error in your browser window (or console) if you use your current code.
如果使用当前代码,您应该在浏览器窗口(或控制台)中看到某种错误。
#2
3
Actually the placement of the jQuery code has nothing to do with this working or not.
实际上,jQuery代码的放置与此工作无关。
The problem is you are using an #
instead of $
to reference the jQuery object. This code should be:
问题是你使用#而不是$来引用jQuery对象。这段代码应该是:
$(document).ready(function() {
...
}
#1
11
Typo:
错字:
#(document).ready(function(){
Should be:
应该:
$(document).ready(function(){
You should see some sort of Error in your browser window (or console) if you use your current code.
如果使用当前代码,您应该在浏览器窗口(或控制台)中看到某种错误。
#2
3
Actually the placement of the jQuery code has nothing to do with this working or not.
实际上,jQuery代码的放置与此工作无关。
The problem is you are using an #
instead of $
to reference the jQuery object. This code should be:
问题是你使用#而不是$来引用jQuery对象。这段代码应该是:
$(document).ready(function() {
...
}