zoukankan      html  css  js  c++  java
  • jQuery 的第一个例子

    通过这个例子可以对jQuery的使用有个基本的认识,jQuery的事件句柄、选择器、基本语法结构,你可以复制这些代码运行感受一下。

    在做第一个例子之前,你需要先到jQuery 1.3 正式版 下载 jQuery库,他是一个js的文件非常的小巧只有那么几十KB,然后就是把这个文件Copy到你的项目,用Script附加这个文件就可以了。

    Code
    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>
    冯瑞涛
  • 相关阅读:
    Bootstrap
    格式化字符串
    闭包函数与装饰器
    正则表达式
    jQuery
    分布式-锁-1.1 多线程锁无法满足的场景
    effective python 读书笔记-第22条: 尽量用辅助类来维护程序的状态,而不要用字典
    effective python 读书笔记:第21条-用只能以关键字形式指定的参数来确保代码明晰
    effective python 读书笔记:第20条-用None和文档字符串来描述具有动态默认值的参数
    git如何将上游(upstream)新建分支(origin没有)导入到origin中?
  • 原文地址:https://www.cnblogs.com/finehappy/p/1377769.html
Copyright © 2011-2022 走看看