Q:

jquery: separate tag and text

I have:
// $(this): <span class="class1"><span class="class2"></span> Some text</span>
$(this).children().each(function () {
    console.log(this);
});

from the console I got only the span with class2, How I can get also the text? something like:
['<span class="class2"></span>', 'Some text']

A:

$(this).children() will only return child nodes that are elements.
You'll want to use $(this).contents() to get all the nodes, including text nodes. :)
You can then filter these nodes to just get elements and text (see node types):
$(this).contents().filter(function() {
  return (this.nodeType === 1) || (this.nodeType === 3);
})

A:

notice the diference between .contents() and .children(). You require the former
While .children() return all available elements, .contents also return text and comments

