日期:2014-05-16 浏览次数:20501 次
$(document).ready(function () { $("#header").css("color", "red"); ... ... ... });
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> <style> </style> <script> window.jQuery ? loadJQ = true : loadJQ =false; var myJQ = function(){ jQuery(function(){ alert( $('#test').html() ); }) }; if(loadJQ){ myJQ(); }else{ var s = document.createElement('script'); s.src = 'http://code.jquery.com/jquery-latest.js'; document.getElementsByTagName('head')[0].appendChild(s); if(s.readyState){ s.onreadystatechange = function(){ if(s.readyState == 'complete' || s.readyState == 'loaded'){ s.onreadystatechange = null; myJQ(); } } }else{ s.onload = function(){ myJQ(); } } } </script> </head> <body> <div id="test">测试</div> </body> </html>