三種動態載入js的jquery例項程式碼另附去除js方法
!-- 這裡為你提供了三種動態載入js的jquery例項程式碼哦,由於jquery是為使用者提供方便的,所以利用jquery動態載入檔案只要一句話$.getscript("test.js");就ok了。 <!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> <meta http-equiv="content-type" content="text/html; charset=gb2312" /> <title>jquery 動態載入js三種方法</title> <script language="網頁特效"> $.getscript("test.js"); //方法二 function loadjs(file){ var head = $('head').remove('#loadscript'); $("<scri"+"pt>"+"</scr"+"ipt>").attr({src:file,type:'text/javascript',id:'load'}).appendto(head); } //夠簡單把!如果在濃縮以下你甚至可以用一行程式碼全部搞定: //方法三 $("<scri"+"pt>"+"</scr"+"ipt>").attr({src:file,type:'text/javascript',id:'load'}).appendto($('head').remove('#loadscript')); </script> </head> <body> </body> </html>
jquery去除js
程式碼如下: $("script[src='../static/js/cpu_memory.js']").remove(); $("script[src='../static/js/wan_flow.js']").remove();