Sam YC
Sam YC

Reputation: 11617

Imported Jquery does not work

I am learning javascript + jquery lately, encounter a problem when trying to import jquery into the html.

I got the code below from internet, while I try to change the line from

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>

to

<script type='text/javascript' src='jquery.js'></script>

it does not work, the script does not execute.

I am sure that the file "jquery.js" is same folder as the html file, and the jquery.js is downloaded from http://jquery.com/download/ (I did change the file name into 'jquery.js' rather than its orginal long name)

What mistake I could possibly made?

Html code:

<!DOCTYPE html>
<html>
<head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>
<script> 
$(document).ready(function(){
  $("button").click(function(){
    $("div").animate({left:'250px'});
  });
});
</script> 
</head>

<body>
<button>Start Animation</button>
<p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;">
</div>

</body>
</html>

Upvotes: 0

Views: 1904

Answers (1)

mr_lewjam
mr_lewjam

Reputation: 1190

this works fine in chrome for me:

<!DOCTYPE html>
<html>
<head>
<script src='jquery.js'></script>
<script> 
$(document).ready(function(){
  $("button").click(function(){
    $("div").animate({left:'250px'});
  });
});
</script> 
</head>

<body>
<button>Start Animation</button>
<p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;">
</div>

</body>
</html>

using a local copy of this version of Jquery http://code.jquery.com/jquery-1.8.2.min.js

Upvotes: 1

Related Questions