初识jQuery

        今天上课讲jQuery的东西,之前写过点js,觉得挺烦的,所以jQuery还是极好的东西,不搞设计,我是多么希望我能设计美得东西。

        学习网站;W3C

        1 什么是jQuery?

               简言之 ,就是一个轻量级的javascript库,许多东西里面都分装好了,较直接写js,这样方便多了,就相当于C++中的STL库。

  

       2 基本语法

              

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>jQuery test</title>
    <script src="script/jquery-1.10.2.min.js"></script>
    <script>
        $(document).ready(function() {
            $("button").click(function () {
                $("p").hide();
            })

            $("a").click(function () {
                alert("hello world");
                $(this).hide();
            })

            $("#btn").click(function () {
                alert("hello world123");
            })
        
            //让段落文本隔行显示不同文本
//             $("p:even").css("background-color", "white");
//             $("p:odd").css("background-color", "blue");
            //多重选择
            $("h1.class1").css("border", "solid 1px #ccc");

            //添加鼠标 移动事件 移动到文本上显示 红色 离开显示蓝色
            $("p").mouseover(function () {
                $(this).css("background-color", "red");
            })
            $("p").mouseout(function () {
                $(this).css("background-color", "blue");
            })
        })
 
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <button type="button">click me</button>
       <p>hello world</p>
       <p>hello world</p>
       <p>hello world</p>
       <p>hello world</p>
       <p>hello world</p>
       <h1 class="class1">hello world6</h1>
        <h1>hello world7</h1>
      
      
        <a href="http://www.sina.com" target="_blank">sina</a>
        <a href="http://www.baidu.com" target="_blank">baidu</a>
        <a href="http://www.qq.com" target="_blank">tecent</a>
        
        <input type="button" id="btn" value="click">
    </div>
    </form>
</body>
</html>
          代码要写在$(document).ready()里面

          $() 代表 选中里面的项,括号里面的标签是CSS的选择器,有标签选择器,类选择器,id选择器.... 

          $(this)代表选中当前项,对当前项执行操作




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值