jquery 在页面中三种写法


jQuery 分 2 个系列版本 1.x 与 2.x,主要的区别在于 2.x 不再兼容 IE6、7、8浏览器,这样做的目的是为了兼容移动端开发。由于减少了一些代码,使得该版本比 jQuery 1.x 更小、更快。
如果开发者比较在意老版本 IE 用户,只能使用 jQuery 1.9 及之前的版本了。
jQuery是一个JavaScript脚本库,不需要特别的安装,只需要我们在页面 <head> 标签内中,通过 script 标签引入 jQuery 库即可。

 1 <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
 2 <script>
 3         // 第一种写法
 4         $(function(){  5             $("div").html("");  6 // add your code here
 7  })  8 
 9         // 第二种写法
10         $(document).ready(function(){ 11             $("div").html(""); 12             $("a").click(function(){ 13 // add your code here
14  }) 15  }) 16 
17         // 第三种写法
18         window.onload = function(){ 19 // add your code here
20  } 21     </script>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM