式:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>动态加载Jquery库,不用创建Ajax请求。在 a 的 href 属性中写一段或多段代码</title> <style type="text/css"> #message { margin: 20px 10px; color:Green; } </style> <script language="javascript" type="text/javascript"> function AjaxLoadJquerylibrary() { var d = document, s = d.getElementById('firebug-lite'); if (s != null) return; s = d.createElement('script'); s.type = 'text/javascript'; s.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js'; d.body.appendChild(s); document.getElementById("content").style.display = "block"; } </script> </head> <body> <div> <input type="button" value="动态导入Jquery" onclick="AjaxLoadJquerylibrary();" /><br /> </div> <div id="message"> </div> <div id="content"> 请输入您的名字:<input type="text" value="" id="txtUserName" /><br /> <a href="javascript:(function(){ var username = $('#txtUserName').val(); alert(username); })();void(0);">Jquery获取名字</a> </div> </body> </html>