Hi,

> hmm, well, links[0] is returning a string, not the a object...

No, it isn't.  Richard already answered your question:  Your alert
coerces the object into a string, which implicitly calls the toString
method on it, which (in the case of a link) returns the href.  If you
actually _try_ what he suggested, you'll see that he's right.

Here's a page demonstrating this stuff:
http://pastie.org/422726

If you run that in a browser, the output is:
* * * *
links.length = 4
typeof links[0] = object
links[0].id = one
links[0].href = http://prototypejs.org/api
links[0].innerHTML = Prototype API
links[0] dumped via implicit call to toString: http://prototypejs.org/api
-------------
The full array:
Link "one" ("Prototype API") links to http://prototypejs.org/api
Link "two" ("Google (U.S.)") links to http://www.google.com/
Link "four" ("Example") links to http://example.com/
Link "five" ("BBC News") links to http://news.bbc.co.uk/
* * * *

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Mar 20, 5:01 pm, tkane2000 <tkthomp...@gmail.com> wrote:
> hmm, well, links[0] is returning a string, not the a object, so those
> will both return null.
>
> The question is why does this statement:
> $$('.gallery .thumb .listItem .thumbHolder');
> return the value of href (a string) and not that a object?
>
> Thanks!
>
> On Mar 20, 6:38 am, Richard Quadling <rquadl...@googlemail.com> wrote:
>
> > Almost certainly you are seeing the results of a toString() method
> > kicking in for the objects (or similar).
>
> > Try ...
>
> > alert("links[0]:" + links[0].id + ':' + links[0].href);
>
> > Richard Quadling.
>
> > 2009/3/20 tkane2000 <tkthomp...@gmail.com>:
>
> > > How come the $$() function returns the value of the href when
> > > selecting an anchor tag instead of the tag itself?  ...I've had mixed
> > > results for this btwn FF and IE6, but it's consistant in the code
> > > below.  Anyone know what I'm doing wrong here or if there's a
> > > workaround?
>
> > > <div id="gallery">
> > >        <div class="thumb">
> > >                <div class="listItem">
> > >                        <a href="/asdfasdf/asdfsdf.jhtml" 
> > > class="thumbHolder">this is some
> > > text</a><br />
> > >                        <a href="/asdfasdf/asdfsdf.jhtml" 
> > > class="thumbHolder">this is some
> > > text</a><br />
> > >                </div>
> > >        </div><br />
> > >        <div class="thumb">
> > >                <div class="listItem">
> > >                        <a href="/asdfasdf/234234.jhtml" 
> > > class="thumbHolder">this is some
> > > text 21</a><br />
> > >                        <a href="/asdfasdf/234234.jhtml" 
> > > class="thumbHolder">this is some
> > > text 23</a><br />
> > >                </div>
> > >        </div>
> > > </div>
>
> > > <script type="text/javascript">
> > >        var links = $$('.gallery .thumb .listItem .thumbHolder');
> > >        alert("links[0]:" + links[0]);
> > > </script>
>
> > --
> > -----
> > Richard Quadling
> > Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498&r=213474731
> > "Standing on the shoulders of some very clever giants!"
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to