<!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=utf-8" />
<title>无标题文档</title>
</head>
<body>
<script type="text/javascript" src="../../js库/jquery-2.1.0.js"></script>
<script>
//JavaScript的文档加载完成事件
window.onload = function(){
alert("JavaScript的文档加载完成事件1");
}
//此时1的代码不会被省略掉
window.onload = function(){
alert("JavaScript的文档加载完成事件2");
}
window.onload = function(){
alert("JavaScript的文档加载完成事件3");
}
//jQuery文档加载完成事件
jQuery(document).ready(function() {
alert("Query文档加载完成事件1");
});
//jQuery可用$代替
$(document).ready(function() {
alert("Query文档加载完成事件2");
});
//最简写法
$(function(){
alert("Query文档加载完成事件3");
});
//总结:同样是文档加载完成后的事件,但是jQuery的代码会邮箱执行且全部执行,
//而JavaScript的代码只会执行最后一个
</script>
</body>
</html>
1.2 js与jq的差异性
最新推荐文章于 2024-10-26 09:45:08 发布