OK, I tried including escaped line breaks (i.e. carriage return / line feed) and if I try View Selection Source in FF, I can see that they are indeed causing line breaks at the appropriate places, however, I'm still missing my self-closing slash.
Next I tried, escaping the slash not with a backslash but as a unicode character like the line breaks (\u002F). All these continue to produce the same malformed image tag...
<img alt="close" src="close_x_gray.gif" style="float: left;">
At this point I wondered if jQuery might be processing this into the same output so the tag <img blah blah blah /> looked the same whether the result was escaped or not. Therefore, I tried to write something which would process into "\/" and be read correctly (assuming that's even correct). Therefore I escaped both slashes (\u005C\u002F). That didn't work, though it at least produced something different...
<img \="" alt="close" src="close_x_gray.gif" style="float: left;">
However, I don't believe that really an improvement. $("#mainSelectionRight img").click(StartTheSearch); doesn't work in IE8, FF3.6, or O11, so I still can't trigger the search to start over just by clicking on the close image.
Actually, the site is hosted on IIS so I don't even need to check to know that the content-type is "text/html". Someone once told me that's it's possible to get IIS to serve content as "application/xhtml+xml", but I've never seen an MS server actually configured to do it. In MSland, I live where XHTML served as "text/html" is as close as you can ever get.
Is that why the content I'm creating in jQuery is incorrect?