一、jQuery的优点
jQuery是在JavaScript上扩展封装的一个功能很强大的库,它大大提高了代码的编写效率,使得我们编写的代码高效简洁。下面我将大概总结一下jQuery的优点:
1、提供了强大的功能函数
2、解决浏览器兼容问题
3、实现丰富的UI
二、通过一个简单的实例了解jQuery
多说无益,我们直接通过一个实例来了解:
大概功能简介:对Hello world!进行显示、改变和隐藏。
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="jquery-1.3.2.min.js"></script>//在HTML中引入jQuery文件jquery-1.3.2.min.js
</head>
<body>
<div id="hw">Hello world!</div>
<input id="btShow" type="button" value="显示">
<input id="btHide" type="button" value="隐藏">
<input id="btChange" type="button" value="修改内容">
<script>
$("#btShow").bind("click",function(event) {$("#hw").show();});//实现显示功能
$("#btHide").bind("click",function(event){$("#hw").hide();});//实现隐藏功能
$("#btChange").bind("click",function(event){$("#hw").html("Hello world! too!");});//改变div中显示的内容
</script>
</body>
</html>总结:(1)jQuery的I
D选择器:$("#选择器名称")
(2)事件绑定函数bind()
(3)显示和隐藏函数.show()和hide()
(4)修改函数内部html的函数html()