Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simple jQuery script not running

Tags:

jquery

I just have copied a simple script from W3School and cannot get it running: Here it is:

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://Web Testing/js/jquery-1.8.0.min.js">
</script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
</body>
</html>

It works on their Tryit Editor with the following line but does not work even with this line on my Mac under BBEdit

like image 827
romaer Avatar asked Feb 21 '26 10:02

romaer


2 Answers

you ned to include jquery the link you included is not working

try

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

also useing the google hosted libraries is a good option because many other website using it so in most case it will get in browser cache

like image 114
NullPoiиteя Avatar answered Feb 24 '26 00:02

NullPoiиteя


<script src="http://code.jquery.com/jquery-1.8.3.min.js" type="text/javascript">
   <!--left blank-->
</script>



<script type="text/javascript">

  $(document).ready(function(){

       /*Your code*/

     });

</script>
like image 30
Akash Shende Avatar answered Feb 23 '26 22:02

Akash Shende