Reputation: 48916
I have the following code and trying to hide XYZ
. Why isn't it getting hidden using this code?
<html>
<head>
<script type="text/javascript">
$(function(){
$('#hide').hide();
});
</script>
</head>
<body>
<div id="hide">
XYZ
</div>
</body>
</html>
Thanks.
Upvotes: 0
Views: 1408
Reputation: 50966
You have forgot to include jQuery library
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.js'></script>
Upvotes: 2
Reputation: 5200
You are not loading jQuery.
try to load it from Google:
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js'></script>
before your script.
Upvotes: 2
Reputation: 754565
You need to include a reference to jQuery in order to use jQuery functions
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('#hide').hide();
});
Upvotes: 3
Reputation: 71908
You are using jQuery syntax, but you didn't add jQuery itself, that's why.
Add this to the head tag, before your current script block:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
Upvotes: 2