varX = 2;
varY = 3;
 var txt = '#div' + varX+ varY;
alert($(txt).innerHtml);

A couple of things are going on here.

1) If you meant  '#div' + varX+ varY; to come out to #div5 then you
have to do  '#div' + (varX+ varY); because javascript thinks you are
attempting string concatenation on  '#div' + varX+ varY; and treats
them all as strings because one of them is a string.  if you wanted
#div23 then you are doing the right thing.

2) $(selector) does not return a DOM node or NodeList, it returns a
jQuery collection.  If you want access to the nodes inside you can do $
(selector)[0] to access the first node, or $(selector).get(0).  and
then get the innerHTML like $(selector)[0].innerHTML.  jQuery also
provide a shortcut for getting/setting the html: $(selector).html
('content here');

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to jquery-ui@googlegroups.com
To unsubscribe from this group, send email to 
jquery-ui+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to