执行顺序遵循:
1.自上而下。
2.嵌套层级。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试jQuery的ready顺序</title>
</head>
<body>
</body>
<script src="http://cdn.bootcss.com/jquery/3.2.0/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
console.log('1');
$(function(){
console.log('2');
$(function(){
console.log('3');
});
});
});
$(document).ready(function() {
console.log('4');
$(function(){
console.log('5');
});
$(function(){
console.log('6');
});
});
$(document).ready(function() {
console.log('7');
});
</script>
</html>