No, your example doesn't reuse variables. There are two
distinct div elements defined, which are two separate
DOM HTMLElement objects. If they have to _exist_ on
the current page simultaneously, each will use its
own memory.

But if they need to be shown at different times and not
simultaneously, then you could assign them to the same
variable in js code before you fetch the div content from
the server and operate on it, e.g.

  qd=getServerDiv("question1");
 ...some work on qd...
 ... now you need question2:
 qd=getServerDiv("question2");
... now work on question2

The last assignement will discard previous
object referenced by qd and reuse qd label to
reference new object containing HTMLDivElement
with qd.id="question2".

Any auto variable defined inside a function
is released once the function returns. Similarly
the reference count of function arguments  is
incremented on entry into function and decremented
upon return (they may be still referenced by the
caller, hence they are not released if they were
assigned to a named variable at the caller's end).

Regarding your example, note that the id of an
html element is an attribute of that html element
and not a variable name in the global name
space e.g. see layout of HTMLElement
(of which HTMLDivElement is a special case)
on Webkit DOM site:

 http://webkit.org/docs/hierarchy.html


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to