[jQuery] REFACTOR: contents() with index() or indexOf()

[jQuery] REFACTOR: contents() with index() or indexOf()


Hi everyone,
I'd like to know if there's a way to do this without using a for loop.
You can just paste this in Firebug:
var $items = $('<items><item>Hello</item><item>world</item>!!<item
id="my_item">Goodnight moon!</item></items>');
for(var i=0; i <= $items.children().length; i++){
if ( $items.contents()[i].id == 'my_item' )
console.info(i)
}
Keep in mind that I need to use contents() to also get the text node
("!!"). I can't seem to use contents().index() properly.
Thanks,
Nacho