<script type="text/javascript">
	console.error(11111);
	$(function(){
		console.error(22222);
	});
	console.error(33333);
</script>

在一般页面的直接加载中,上面这段代码的执行顺序:

关于Ajax load页面中js部分$(function(){})的执行顺序

不过,在使用Ajax加载这个页面到某个div中时,执行顺序发生改变:

关于Ajax load页面中js部分$(function(){})的执行顺序

看来使用Ajax的时候,需要注意这个js的执行顺序。

 

相关文章:

  • 2022-12-23
  • 2022-02-23
  • 2021-10-11
  • 2021-07-04
  • 2021-12-03
  • 2021-12-05
  • 2021-12-22
猜你喜欢
  • 2021-05-18
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案