It seems obvious to me that you are trying to change an element before the page finishes loading. At least exactly what you do on your demo page. You do not carry the code in $(document).ready() in the same way as in the question
Try this demo site instead of http://jsbin.com/ivuqa , which correctly wraps the corresponding lines in ready()
In addition, using XHTML may cause some problems. In this case, just wrap the offensive part of javascript like this. (CDATA satisfies XML validation, a multi-line javascript comment to hide cdata from a browser that does not understand it and therefore will not be able to run javascript.
/* <![CDATA[ */ var tip = "<p>Most computers will open PDF documents automatically, but you may need to download <a title='Link to Adobe website-opens in a new window'"; tip +=" href='http://www.adobe.com/products/acrobat/readstep2.html' target='_blank'>Adobe Reader</a>.</p>"; /* ]]> */
source share