Since the only thing you're doing with the underlying DOM element ('this' in
the callback function) is to wrap it right back up in a $() wrapper, you can
do it much more simply:

   var text = $(html).find('#invoice').text();
   alert( text );

You could also write it this way:

   var text = $('#invoice',html).text();
   alert( text );

If you wanted to do something with the DOM element itself, you'd access it
with [0]:

   var div = $(html).find('#invoice')[0];
   alert( div.tagName );

Both of these snippets assume that there is only one element in the query
result - which should be the case since you're using the ID to select it.

-Mike

> From: Dustin
> 
> You're right, I had pasted the code snippet from another 
> script and forgot to change the code. I do only have a 
> question though. If am only meaning to look for an ID that 
> only exists once, what would be the syntax for that?
> For example, right now I have
> 
> $(html).find('#invoice').each(function(){
>      var invalidDiv = $(this).text();
>      alert(invalidDiv);
> });

Reply via email to