Blogger Information
Blog 34
fans 2
comment 2
visits 22737
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
$(document).read()使用方式与简写-20180403 15:09
AsNwds_MIS王的博客
Original
1180 people have browsed it

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>


</head>

<body>

<h2>php</h2>

<p>jquery</p>



</body>

</html>

<script type="text/javascript" src="js/jquery-3.3.1.js"></script>

<script type="text/javascript">

    $(document).ready(function(){

    $('h2').css('font-size','200%');

});


</script>


<script type="text/javascript">

$(function(){

    $('p').append('&nbsp;hello!');

});

</script>

以上是两种方式

<script type="text/javascript">

window.onload=function(){

    alert('hello');

};

</script>


window.onload和$(document).ready(function(){})的区别 

在于前者是所有元素全部加载到浏览器才能执行

后者DOM结构加载完毕才能执行,大大缩短了用户等待的时间。

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post