$('#message") returns a jQuery object, which is 'array-like' (as the
docs say). Arrays start at position zero, so [0] is asking for the
first element in the array (which happens to be the only one).

For example, $('#list li')[2] would give you the 3rd element from that
object. Note that this gives you a standard HTML element, with no
jQuery functions attached. 'value' is a native property.

Essentialy, $('#message')[0] or $('#message').get(0) or
document.getElementById('message') all return exactly the same.

- ricardo

On Sep 23, 12:13 pm, Stinhambo <[EMAIL PROTECTED]> wrote:
> Wow that's great and it works too! What is the square bracket and zero
> for?
>
> On Sep 23, 11:14 pm, BB <[EMAIL PROTECTED]> wrote:
>
> > The smallest thing would be:
>
> > $("#message")[0].value += window.opener.location.href;
>
> > On 23 Sep., 15:09, Stinhambo <[EMAIL PROTECTED]> wrote:
>
> > > I managed to achieve what I wanted with this -
>
> > > document.getElementById('message').value +=
> > > window.opener.location.href;
>
> > > in the jquery file but I can't work out the proper jquery way. I'd
> > > love to know!
>
> > > On Sep 23, 9:42 pm, Stinhambo <[EMAIL PROTECTED]> wrote:
>
> > > > Hi all!
>
> > > > I have some js that opens a popup window based on the rel attribute -
>
> > > > $('a[rel="email_page"]').click(function(){
>
> > > > window.open(this.href,'mywindow','height=580,width=400,scrollTo,resizable=0,scrollbars=0,location=0','false');
> > > >         return false;
> > > >     });
>
> > > > But what I want to achieve is to pass the parent url
> > > > (window.opener.href?) to the popup window and append the URL to the
> > > > contents of a textarea -
>
> > > > <textarea id="message" name="message" rows="18" cols="40">I wanted to
> > > > send you a link to - ** ADD URL HERE ** </textarea>
>
> > > > Any ideas?

Reply via email to