user964147
user964147

Reputation: 739

Why this jquery code is not working for me?

I wrote very samll code in jquery, but i am unable execute it Where i am wrong?

<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js">    
<script type="text/javascript">
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
});
</script>
</head>

<body>
<p>If you click on me, I will disappear.</p>
</body>

</html> 

Any help will be greatly appriciated.

Upvotes: 0

Views: 550

Answers (4)

Soojoo
Soojoo

Reputation: 2166

Close the script tag inside the head tag.

<html>
<head>
  <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js">  </script>   
  <script type="text/javascript">
    $(document).ready(function(){
    $("p").click(function(){
    $(this).hide();
   });
  });
  </script>
</head>

<body>
  <p>If you click on me, I will disappear.</p>
</body>

</html> 

Upvotes: 0

Anoop
Anoop

Reputation: 23208

You forgot to close script tag

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"> </script>

Upvotes: 2

David G
David G

Reputation: 96865

You did not close the first script tag:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>

Upvotes: 3

Darin Dimitrov
Darin Dimitrov

Reputation: 1039508

You forgot to close your script tag for jquery. It should be like this:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('p').click(function() {
            $(this).hide();
        });
    });
</script>

Notice the closing </script> tag

Upvotes: 3

Related Questions