JQuery(一) 入门

JQuery是一个JS库,可以跨浏览器运行,若开发者面对jQuery编程,则可以在不同的浏览器自由切换。

jQuery不再像JS一样面向DOM,而是面向jQuery对象。

jQuery提供$()函数,用于获取DOM元素。


实例一:

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("p").click(function(){
  $(this).hide();
  });
});
</script>
</head>

<body>
<p>If you click on me, I will disappear.</p>
</body>

</html> 

jQuery 官网下载,Production是去除了注释的,体积较小。development是未压缩的且保留了注释。


 

jQuery与其它库关于$()冲突解决。

//取消jQuery $()函数,用jQuery()代替
jQuery.noConflict();

或者给jQuery()函数取一个别名

//取消jQuery $()函数,用othername代替
var othername = jQuery.noConflict();
//此后可用othername()替代$()函数

 

posted @ 2015-03-09 18:56  Java_Code  阅读(117)  评论(0编辑  收藏  举报