jQuery 的第一个例子
2009-01-18 10:34
274 查看
通过这个例子可以对jQuery的使用有个基本的认识,jQuery的事件句柄、选择器、基本语法结构,你可以复制这些代码运行感受一下。
在做第一个例子之前,你需要先到jQuery 1.3 正式版 下载 jQuery库,他是一个js的文件非常的小巧只有那么几十KB,然后就是把这个文件Copy到你的项目,用Script附加这个文件就可以了。
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery.js" type="text/javascript"></script>
<style type="text/css">
.red
{
background-color: Red;
}
.green
{
background-color: Green;
}
.blue
{
background-color: Blue;
}
</style>
<script type="text/javascript">
$(document).ready(
function() {
$("div").addClass("blue");
//$("#olID>li").addClass("green");
$("#olID>li").hover(
function() {
$(this).addClass("red")
},
function() {
$(this).removeClass("red")
});
$("#olID>li:last").hover(
function() {
$(this).addClass("green");
},
function() {
$(this).removeClass("green");
})
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ol id="olID">
<li>Terry.Feng.C</li>
<li>冯瑞涛</li>
<li>f@gmail.com</li>
</ol>
</div>
</form>
</body>
</html>
在做第一个例子之前,你需要先到jQuery 1.3 正式版 下载 jQuery库,他是一个js的文件非常的小巧只有那么几十KB,然后就是把这个文件Copy到你的项目,用Script附加这个文件就可以了。
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery.js" type="text/javascript"></script>
<style type="text/css">
.red
{
background-color: Red;
}
.green
{
background-color: Green;
}
.blue
{
background-color: Blue;
}
</style>
<script type="text/javascript">
$(document).ready(
function() {
$("div").addClass("blue");
//$("#olID>li").addClass("green");
$("#olID>li").hover(
function() {
$(this).addClass("red")
},
function() {
$(this).removeClass("red")
});
$("#olID>li:last").hover(
function() {
$(this).addClass("green");
},
function() {
$(this).removeClass("green");
})
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ol id="olID">
<li>Terry.Feng.C</li>
<li>冯瑞涛</li>
<li>f@gmail.com</li>
</ol>
</div>
</form>
</body>
</html>
相关文章推荐
- jQuery 的第一个例子
- mvc jquery ajax json 第一个mvc中第一个ajax例子。
- jQuery 的第一个例子
- 第一个jquery例子
- ajax+json+jquery第一个mvc例子
- jQuery从0开始之【一】jQuery的引入及第一个例子
- jQuery 第一个例子
- jQuery 的第一个例子
- jQuery 学笔记,jQuery的第一个例子
- Autofac 解释第一个例子 《第一篇》
- Jquery 表格颜色交替变化鼠标移过颜色变化的例子
- 今天使用Django测试第一个小例子的时候,遇到了NameError: name 'include' is not defined错误
- jquery实现文本框数量加减功能的例子分享
- 学习Spring.NET - 第一个例子
- 我的第一个jQuery脚本 ——弹出一个提示对话框
- Android中的第一个NDK的例子
- 第一个cuda例子
- RequireJS入门一之实现第一个例子
- jQuery随机切换图片的小例子
- RequireJS入门一之实现第一个例子