[jQuery] Re: selectors

2008-09-02 Thread Michael Geary

Imagine that you have an array:

var a = [ 'a', 'b', 'c' ];

Now you can call array methods on the array:

   var t = a.join();  // 'a,b,c'

But what happens if you call an array method on one of the *elements* of the
array?

   var x = a[0].join();

That's an error, because a[0] is a *string*, not an array.

In the same way, $(whatever) returns a jQuery object, with jQuery methods
such as .val(), .css(), etc. The jQuery object is also an array-like object,
so you can retrieve the array elements with [0], [1], etc. But those array
elements are *DOM nodes*, not jQuery objects themselves.

So, $(whatever)[0] gives you a DOM node, with properties like defaultValue,
but this DOM node does not have the jQuery methods, because it's not a
jQuery object.

-Mike

> for this form
> 
>   
>   
> 
> 
> why
> $("#searchform input")[0]
> is different than
> $("#searchform input:first")
> 
> I can get  values for $("#searchform input")[0].defaultValue 
> or .value but not with .fadeIn() or val() while the reverse 
> for the $ ("#searchform input:first")



[jQuery] Re: error $ not defined

2008-09-02 Thread Chris

I found this to be the trouble I am having  - however it is localized
to only my development server (localhost in this case)

Using firebug I have confirmed that the jquery.js script is not being
found when I load the page via localhost/domain/jquerytest.htm.
However all the other js files are loaded correctly.  Also on the
server the jquery.js file is located and served correctly.

Anyone have any ideas what I could be missing on my local machine that
would cause this one js file to not be found?

thanks,
Chris

On Aug 20, 9:24 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> This error appears when the core jQuery fie is not included, either  
> because there is no script tag with a src attribute pointing to it or  
> because the src attribute is pointing to the wrong place. It can also  
> appear when you include scripts that use jQuery before you include the  
> core jQuery file.
>
> Since it looks like you have a reference to it, and the reference is  
> coming before any references to scripts that use it, my only other  
> guess is that it's pointing to an incorrect location. Try opening the  
> "Script" tab in Firebug and examining the jquery.js script. If it  
> shows you some html instead of javascript, then you're getting a 404.
>
> Another way you could troubleshoot this is to paste this next line in  
> and use it instead of your "":
>
>      http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js
> " type="text/javascript">
>
> If that one works, then most likely your other one is getting a 404.
>
> Hope that helps.
>
> --Karl
>
> 
> Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> On Aug 20, 2008, at 7:13 PM, larksys wrote:
>
>
>
> > I'm trying to apply what I know so far to my CF page and an
> > autosuggest input field. The very first line of javascript give an
> > error;
>
> > $ not defined
> > $(document).ready(function(){
>
> > The java script files are included ( I checked that)
> > The css files are included (I checked that)
>
> > 
> > 
> >  > script>
>
> > And this script;
>
> >