jquery中ready函数,$(function(){})与自执行函数的区别

it2022-05-08  8

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script type="text/javascript" src="js/jquery-1.12.1.js"></script> <script type="text/javascript">

/** * jQuery中的ready函数 * */ var jq = jQuery(document); /*jQuery(document).ready(function(){ console.log("ready1") }); jQuery(document).ready(function(){ console.log("ready2") });*/ jq.ready(function(){ console.log("ready1") }); jq.ready(function(){ console.log("ready2") });

(function(){ console.log("自执行") })(); $(function(){ console.log("jquery 自执行"); });

//console.log(jQuery(document) === jQuery(document)) </script></head><body>

</body></html>

转载于:https://www.cnblogs.com/hwgok/p/5898532.html

相关资源:JQuery的ready函数与JS的onload的区别详解

最新回复(0)