• 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三种方法-www.jbxue.com</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>
  • 相关阅读:
    Python格式化输出
    每天写点shell脚本 (持续更新)
    linux limits.conf 配置
    ELK 日志分析系统
    开源大数据处理工具
    glusterFS分布式存储部署流程
    glusterFS的部署流程
    parted命令详解
    /proc文件系统
    /proc文件系统(二):/proc/<pid>/stat
  • 原文地址:https://www.cnblogs.com/cfinder010/p/3234481.html
Copyright © 2020-2023  润新知