The following JavaScript code will automatically load jQuery if it is not already loaded on the current page. This is particularly useful if you need to load jQuery into a bookmarklet. It's also useful in any situation where you can access the JS code on the page but not the HTML code.
// ------------------------------------------------------------------------- // Load JQuery if it's not already loaded. // ------------------------------------------------------------------------- function loadJQuery() { //if the jQuery object isn't available if (typeof(jQuery) == 'undefined') { // Load jQuery from Google var fileref=document.createElement('script') fileref.setAttribute("type","text/javascript") fileref.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js") document.getElementsByTagName("head")[0].appendChild(fileref); } }