jQuery's tolerance on the dirtiness of html files

jQuery's tolerance on the dirtiness of html files

I wonder how dirty of an html file jQuery can tolerant and still produce correct result in selecting, traversing, etc? Does it require the html file having a perfect well-structured DOM?