<html>
<head>
<script type="text/javascript" src="jquery-1.4.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("p.test2").click(function(){
$("p#test").hide();
$("p.test2").css("color","red");
});
});
</script>
</head>
<body>
<p id="test">If you click on the below,I will disappear!</p>
<p class="test2">If you click on me,I will be red!</p>
</body>
</html>
下载附件的jquery-1.4.js,把以上代码复制到文本文件中,再把文本文件重命名为html文件。最后把jquery-1.4.js和html文件放一块,打开html文件就能轻松体验jQuery的方便!
这只是个简单的例子,jQuery就是一个JavaScript库,jQuery库位于单个的JavaScript文件中,其中包含所有的jQuery函数,需要大家自己看jQuery文档,简化各种JavaScript的编程,这就是封装的效应!