Simplicity
Simplicity

Reputation: 48916

jQuery - Hiding text

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

Answers (5)

genesis
genesis

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

CamelCamelCamel
CamelCamelCamel

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

JaredPar
JaredPar

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

Mike G
Mike G

Reputation: 4793

You need to include jQuery.js in your source file.

Upvotes: 2

bfavaretto
bfavaretto

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

Related Questions