logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > Javascript and JS frameworks
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 01-23-2013, 06:46 PM   #1
tony09uk
 
Join Date: Oct 2010
Posts: 340
Default making jquery work

Hi, I am trying to learn jquery and seem to be struggling to get it to work, can someone please help.

So far I have gone to Jquery and copied and pasted the source code into a .js file which I have name jquery.
I have referenced the file <script src="jquery.js"></script> in the body of my practice page.

I then added

<script>

var lis = jquery('ul li').css('color', 'green');

</script>

and in the browser using the developer tools I got the following message
"Uncaught ReferenceError: jquery is not defined "
I assume i have got something worng, can you please help?
tony09uk is offline   Reply With Quote
Old 01-24-2013, 09:04 AM   #2
Corrosive
Corrosive's Avatar
 
Join Date: Feb 2008
Location: Bristol, England
Posts: 7,103
Default

Check all of your paths and locations.
Corrosive is offline   Reply With Quote
Old 02-01-2013, 05:55 AM   #3
jmichae3
 
Join Date: Dec 2010
Posts: 366
Default

Quote:
Originally Posted by tony09uk View Post
Hi, I am trying to learn jquery and seem to be struggling to get it to work, can someone please help.

So far I have gone to Jquery and copied and pasted the source code into a .js file which I have name jquery.
I have referenced the file <script src="jquery.js"></script> in the body of my practice page.

I then added

<script>

var lis = jquery('ul li').css('color', 'green');

</script>

and in the browser using the developer tools I got the following message
"Uncaught ReferenceError: jquery is not defined "
I assume i have got something worng, can you please help?
try sourcing that js file BEFORE you try to use any of its functions. you will have better success then.
like this:
Code:
<script src="jquery.js"></script><!--sorry, can't place code in there except comments-->
<script>
    var lis = jquery('ul li').css('color', 'green');
    </script>
also, are you sure you are cqalling it right? every place I have seen references the page as $, so I should think it's something like
Code:
<script src="jquery.js"></script><!--sorry, can't place code in there except comments-->
<script>
    var lis = jquery('ul li').css('color', 'green');
    </script>
I am definitely no jquery expert here. I would have to get a book like anyone else. but this is from what little exp I have had with jquery. $ is just another identifier character in js according the the BNF grammar (language spec), and jquery makes explicit use of that character for an identifier.

an identifier is used for things like a function or variable name.
__________________
------------
Jim Michaels
HTML Code:
improperly<strong>nested<em>elements</strong>cause</em>
browser confusion (I believe the term is 'tag soup')!
jmichae3 is offline   Reply With Quote
Old 02-01-2013, 06:13 AM   #4
jmichae3
 
Join Date: Dec 2010
Posts: 366
Default

http://api.jquery.com/jQuery/

I think you have the case wrong. js in browsers is case sensitive on identifiers.
should be jQuery not jquery. fix that.
__________________
------------
Jim Michaels
HTML Code:
improperly<strong>nested<em>elements</strong>cause</em>
browser confusion (I believe the term is 'tag soup')!
jmichae3 is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:37 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com