That's because z is not defined at that point in time.  You're assigning z
in the doc-ready handler which is not invoked until the DOM is fully
loaded.  But you're document.write call is executed as soon as it is
parsed.  What exactly are you trying to do?

Mike


On Dec 2, 2007 2:56 PM, Ryura <[EMAIL PROTECTED]> wrote:

>
> Thanks for the reply, Mike.
>
> I've tried that but I'm still thrown the error z is not defined
> $(function(){
> z=$("#getID").text();
> });
> document.write(z);
>
> On Dec 2, 2:38 pm, "Mike Alsup" <[EMAIL PROTECTED]> wrote:
> > Drop the 'var' keyword and you'll get a global variable.
> >
> > Mike
> >
> > On 12/2/07, Ryura <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > Right now I have this code:
> >
> > > $(function(){
> > > var z=$("#getID").text();
> > > });
> > > document.write(z);
> >
> > > Obviously this does not work. But how can I make it work? In the
> > > situation I am in, I cannot put all the code inside the
> > > function...surely there must be some way.
> >
> > > Thanks :)
>

Reply via email to