a screen shot to illustrate my point ... if I can venture an non-expert diagnostic, it seems that in the second case jQuery considers that the html in the contains() statement is the "context" of the statement and not the html document ...
EuGeNe -- http://www.3kwa.com
<<inline: contains.png>>