DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> JavaScript綜合知識 >> jquery動態加載js三種方法實例
jquery動態加載js三種方法實例
編輯:JavaScript綜合知識     
這裡為你提供了三種動態加載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>

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved