js jquery 页面加载初始化方法

JQuery.js(导入文件) Jquery是继prototype之后又一个优秀的Javascrīpt框架。它是轻量级的js库(压缩后只有21k) ,它兼容CSS3,还兼容各种浏览器 (IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+)。jQuery使用户能更方便地处理HTML documents、events、实现动画效果,并且方便地为网站提供AJAX交互。jQuery还有一个比较大的优势是,它的文档说明很全,而且各种应用也说得很详细,同时还有许多成熟的插件可供选择。jQuery能够使用户的html页保持代码和html内容分离,也就是说,不用再在html里面插入一堆js来调用命令了,只需定义id即可。 立即下载

https://www.cnblogs.com/ooo0/p/6123465.html

 

一.js 页面加载初始化方法


<body onload='init()'>
</body>

<script type="text/javascript">
    function init(){
         // 初始化内容       
    }
</script>

// 2.window.onload=function(){}
<script type="text/javascript">
    window.onload=function(){ 
        // 初始化内容 
    }
</script> 

// 3.写初始化方法,页面顺序执行到初始化方法时初始化
<script type="text/javascript">
    function init() { 
        // 初始化内容
    }; 
    init(); 
</script>

二.jquery 页面加载初始化方法

// 1.$(function(){})
<script type="text/javascript">
    $(function() {// 初始化内容
    });  
</script>

// 2.$(document).ready(function(){})
<script type="text/javascript">
    $(document).ready(function(){  
        // 初始化内容
    });  
</script>

// ready()函数有以下三种等价的形式
function handler(){
    //这里是需要执行的代码
}

// 形式一
$(document).ready( handler );
// 形式二
$( ).ready( handler ); // 不推荐该形式
// 形式三
$( handler );
 

// 3.jQuery(function($){})
<script type="text/javascript">
    jQuery(function($){  
        // 初始化内容
    });  
</script>

三.jquery和js初始化加载页面的区别
jquery:等待页面加载完数据,以及页面部分元素(不包括图片、视频), 
js:是页面全部加载完成才执行初始化加载。

 

css和jquery实现页面加载前的等待界面 一般我们进入网站后需要等待数据加载后才完整显示,如果加入一个等待界面,等数据加载完毕后再消失等待界面那用户体验就会好点 立即下载

相关推荐

jquery加载页面的方法(页面加载完成就执行)

jquery加载页面的方法(页面加载完成就执行),建议大家看下windows.onload与$(document).ready之间的区别。

JavaScript 学习笔记 - 15 用 jQuery 设计页面

我们将讨论 Web 2.0 界面外观,包括如何创建以及为什么使用它。为了说明这些问题,我们将深入介绍 jQuery 和 jQuery UI 的优点和用法。然后讨论如何突出显示元素、创建可折叠菜单和显示模态对话框,并实现相关联的视觉效果。我们还会涉及更智能的日期选择器,既能显示一个月也能显示两个月。最后为大家展示如何创建自定义主题。

泛红尘的博客 1547

231003-四步MacOS-iPadOS设置无线竖屏随航SideCar

新建虚拟屏幕参考文献。

专注机器学习之路 7484

页面加载完成后再执行JS的jquery写法以及区别说明

1、$(function(){    $("#a").click(function(){      //adding your code here    });  });  2、$(document).ready(function(){    $("#a").click(function(){      //adding your code here      });  }); 

海阔天空的博客 1187

阿里云百炼接入本地Claude,接入idea

阿里云百炼平台提供两种接入方式:未购买套餐时使用通用API Key(sk-xxxxx),需注意免费额度独立计算且不会自动切换模型;购买Coding Plan套餐后使用专属API Key(sk-sp-xxxxx),享受固定月费无超支风险。配置需在.claude/settings.json中设置认证信息,包括API Key和Base URL。建议开启"用完即停"功能避免意外扣费,不同模型的免费额度互不影响。购买套餐后还可通过IDEA插件Claude Code进行集成,实现固定费用下的稳定使用

fengtangjiang的博客 1355

K8s(二十一):在 Kubernetes 集群中部署 MySQL8.0 高可用集群(1主2从)

🔴 K8s(二十一):在 Kubernetes 集群中部署 MySQL8.0 高可用集群(1主2从)

✨ 欢迎来到【Seal ^_^ 的优快云博客】!✨ 3万+

利用jQuery实现动态加载页面内容并融入当前页面的全面解析

jQuery作为一款广泛使用的JavaScript库,提供了丰富的API以简化DOM操作和AJAX请求,使得开发者能够轻松实现将远程页面内容加载到当前页面的功能。通过jQuery提供的强大功能,我们可以方便地将远程页面的内容无缝融合到当前页面中,极大地增强了网页的交互性和灵活性。在实际应用中,还需根据具体需求,综合运用AJAX的各种方法,以及恰当的缓存控制、事件处理和错误处理策略,确保页面动态加载功能既高效又稳定。.ajax()方法的便捷封装,特别适用于简单的页面片段加载场景。

Programming Talk 1301

大语言模型应用指南:幻觉和偏见问题

大语言模型应用指南:幻觉和偏见问题 1. 背景介绍 1.1 大语言模型的发展历程 1.1.1 早期的语言模型 1.1.2 Tr

AI天才研究院 958

关于页面加载即执行JQuery的三种方法小结

第二种是第一种的完整形式。

zlq_hh的专栏 789

9.9华为OD机试真题 新系统 - 受限任务分配 (Java/Py/C/C++/Js/Go)

华为OD机试真题 新系统【受限任务分配】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题 【受限任务分配】多语言题解。

qq_45776114的博客 723

硬核实战!Python爬虫从0到1完整版:爬取知乎热榜+回答内容(数据去重+Excel一键导出+避坑指南,零基础友好)

✔️ 适用人群:Python爬虫零基础、想练手实战爬虫、需要爬取知乎内容做数据分析、办公/学习素材整理的同学爬取知乎热榜全量数据(排名+标题+热榜链接+热度值) →自动跟进爬取每个热榜问题的回答内容(回答者昵称+赞同数+评论数+回答正文+发布时间) →数据清洗+智能去重→一键导出格式化Excel文件,所有功能一站式完成入门级难度,无复杂反爬破解、无分布式/代理池,纯requests请求+静态解析,新手能看懂、能运行、能修改;爬取速度快,热榜+回答全程仅需几十秒。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1460

jQuery基础教程:页面加载、对象转换与选择器详解

单纯像沙漠中的花,周围是咆哮的风沙。

chaosweet的博客 918

超强干货之---Python-数据爬取(爬虫)

定义: 深度优先搜索是一种遍历或搜索树或图的算法,从起始节点开始,一直沿着一个分支走到底,再回溯到上一个节点继续搜索下一个分支,直到遍历完所有节点。特点递归:通常用递归实现,或者使用栈来模拟递归过程。内存占用低:在有大量分支的情况下,内存占用比广度优先搜索低。适合目标较深的情况:如果目标节点距离起始节点较深,DFS能更快找到目标。适用场景需要遍历所有节点的情况,如生成树、迷宫搜索。目标节点较深,且分支较多时。在大规模数据爬取时,选择合适的存储方式取决于数据的规模、结构和访问需求。

房东的猫的博客 5万+

JavaScript # 前端 jquery 页面加载初始化方法

No.1 .js 页面加载初始化方法 // 1.在body里面写初始化方法. <body onload='init()'> </body> <script type="text/javascript"> function init(){ // 初始化内容 } </script> No.2...

qq_16313575的博客 732

LLCC68芯片系统架构与LoRa驱动开发核心解析

LoRa射频收发器是低功耗广域物联网(LPWAN)的关键组件,其本质是集成了调制解调器、协议引擎、数据缓冲区与电源管理的专用SoC。理解其工作模式状态机(Sleep/Standby/TX/RX)与SPI主机接口时序规范,是实现稳定通信的基础。LLCC68通过寄存器映射与命令集双接口抽象硬件控制,支持LoRa扩频调制与FSK兼容模式,具备高链路预算(157 dB)和DC-DC/LDO动态电源切换能力。典型应用场景包括远距离传感器节点、智能表计与工业无线监测系统。本文深入剖析LLCC68的信号链路径、中断机制与

weixin_29859471的博客 281

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

js、 jquery 页面加载初始化方法及区别

js、 jquery 页面加载初始化方法及区别一.js 页面加载初始化方法二.jquery 页面加载初始化方法三.jquery和js初始化加载页面的区别 一.js 页面加载初始化方法 去博客设置页面,选择一款你喜欢的代码片高亮样式,下面展示同样高亮的 代码片. // 1.在body里面写初始化方法. &amp;lt;body onload='init()'&amp;gt; &amp;lt;/body&amp;gt; &amp;lt;s...

毕邺 666

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

JavaScript 跟 jQuery页面加载初始化的方法

JavaScript 页面加载初始化的方法 window.onload = function () { // 执行代码 } jQuery 页面加载初始化的3种方法 方法一: $(document).ready(function(){ // 执行代码 }); 这是为了防止文档在完全加载(就绪)之前运行 jQuery 代码,即在 DOM 加载完成...

BestEternity的博客 397

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

js和 jquery 页面加载初始化方法

js初始化方法 1.body 增加onload事件并绑定函数。 // 1.在body里面写初始化方法. &amp;lt;body onload='init()'&amp;gt; &amp;lt;/body&amp;gt; &amp;lt;script type=&quot;text/javascript&quot;&amp;gt; function init(){ // 初始化内容

shenlanse7626的博客 493

js和jquery页面初始化加载函数的方法及先后顺序

运行下面代码。弹出A、B、C、D、E的顺序:A=B=C>D=E。 jquery:等待页面加载完数据,以及页面部分元素(不包括图片、视频), js:是页面全部加载完成才执行初始化加载。<script> // jquery页面初始化A,B,C $(function(){ alert("A"); }); $(document).ready(function(){ alert("

lorie_yy的博客 1971
上一篇: ASP.NET Core 静态文件及JS包管理器(npm, Bower)的使用
下一篇: javascript插件的几种写法
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值