jQuery入口函数四种写法
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>04-jQuery入口函数的其它写法</title>
<script src="js/jquery-1.12.4.js"></script>
<script>
// 1.第一种写法
$(document).ready(function () {
// alert("hello lnj");
});
// 2.第二种写法
jQuery(document).ready(function () {
// alert("hello lnj");
});
// 3.第三种写法(推荐)
$(function () {
// alert("hello lnj");
});
// 4.第四种写法
jQuery(function () {
alert("hello lnj");
});
</script>
</head>
<body>
</body>
</html>在项目中以上的写法都可以使用,个人比较推荐用第三种写法,简洁方便