PDA

View Full Version : Very, very basic jquery


tony09uk
09-30-2011, 11:09 PM
I have had my first go at jquery and can't even get off the ground I am following this (http://blog.themeforest.net/tutorials/jquery-for-absolute-beginners-video-series/) tutorial but am getting stuck at the first hurdle....and I don't event think it should be a hurdle.

I have downloaded the jquery file and dragged it into my root folder.

I have then inputted this code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home test</title>
<script src="jquery-1.2.6.min.js"type="text/javascript"></script>

<style type="text/css">
#box {
width:200px;
height:200px;
background-color:red;
}
</style>

<script type="text/javascript">

$(function() {
$('a').click(function() {
$('#box').fadeout(5000);
});
});

</script>
</head>

<body>
<div id="box"></div>
<a href="#">Click me!</a>
</body>
</html>

as stated in the tutorial but when I test it in the browser it does nothing.

What have I done wrong?

johnMoss
10-01-2011, 09:25 PM
I can't see a thing wrong here, so
1) The JS file in the root, double check the path...
2) silly, but gotta ask... JS disabled in your browser? You run other JS scripts locally & no issues? If this is a possible reason, javascripts are commonly disabled locally by default browser security settings...

tony09uk
10-01-2011, 09:50 PM
i will check and get back to you. Although i think javascript is enabled, and im 99% sure the path is right too. But i will double check

ranjan
10-02-2011, 03:50 PM
that old old version.

current version is jquery 1.6.4

check your filename is correct in the following section

<script src="jquery-1.2.6.min.js"type="text/javascript"></script>

PS: I wouldnt want to learn from a video thats so old. Even 6 months is an eternity in this industry

tony09uk
10-02-2011, 05:44 PM
I have downloaded that version on Jquery as i am following a tutorial, (granted the video is old, but it will give me the basics and I can then pick up the rest from there) I decided to follow the tutorial like for like, just in-case there are any differences and thus minimizing the chance of any silly little problems, obviously it's not worked lol

Oh javascript is working on local files

tony09uk
10-04-2011, 03:24 PM
I can now confirm that it's not my computer. I have tried the exact same code on a second computer, with no luck. I have the .js file in the root folder. So im sure the path is right. Any ideas or pointers will be greatly appreciated.

johnMoss
10-04-2011, 03:42 PM
Tony I'm right there w/ ya on learning the tools. I've spent the last 10 days or so diving headlong into it. Re-examining your code, I do see a flaw... But lemme have at this in proper order.
1) Take Ran's suggestion and download the latest JQuery. right now it is 1.6.4
2) Be sure to download the minimized version 1.6.4-min.js
3) You have in place above the primary JQuery code, and the initiator, but you do not have the script for the box itself. In other words you are missing one more js file. Go to my site with the hyperlink below and go to the gallery.
4) Look at the last script calls in the head. You'll see the basic JQuery, followed by specialized code scripts for the boxes. After that you'll see the initializer. The specialized is what you are missing, you should have at least one. Go back & find that...
5) Another route is to use what I've got, i.e a working model to play with. I have others also.
6) Last, and this is funny, (now, but not the entire day I spent jacking with it :)), The basic JQuery code script in the head (1.6.4-min) must be called first, if not, things may not work. That drove me bananas until I finally figured that out. (!)

tony09uk
10-04-2011, 05:22 PM
well....John, thanks for your advice mate. I was so close to giving up (I think ive lost count the amount of time ive nearly give up on this website stuff lol). Its now working, though im sure it wont be long before I come back with another little query.

Once again thanks to both of you for your assistance.

johnMoss
10-04-2011, 05:29 PM
Spill bro, what in fact resolved the issue?

tony09uk
10-05-2011, 08:47 PM
i think it was that i didnt call the js file first. I haven't played around with potential things that caused it not to work, im just happy its working now, but im guessing that was the reason

johnMoss
10-05-2011, 08:51 PM
Probably was... glad it's working...