jquery全解(1)

本章内容

这里写图片描述

这里写图片描述

1.jquery语法

这里写图片描述
jquery的使用
<head></head>里引用jquery.js

<!DOCTYPE html>
<html lang="en">
<head>
    <!-- 引用jquery.js -->
    <script src="jquery.js"></script>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
</body>
</html>

jquery 符号
$(“选择器”).动作()
$(“div”).animate({opacity:0},3000);
注:选择器名要加引号
例如操作一个div

<!DOCTYPE html>
<html lang="en">
<head>
<style>
div{width: 100px;height: 100px;background: red;}
</style>
<!-- 引用jquery.js -->
    <script src="jquery.js"></script>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div></div>
    <script>
        //$("选择器").动作(变化,时间) 
        $("div").animate({opacity:0},3000);
    </script>
</body>
</html>

2.juqery效果

这里写图片描述

<!DOCTYPE html>
<html lang="en">
<head>
<style>

div{width: 100px;height: 100px;background: red;}
</style>
<!-- 引用jquery.js -->
    <script src="jquery.js"></script>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div></div>
    <script>
        // $("div").animate({opacity:0},3000);//渐变
        // $("div").hide(3000)//隐藏
        // $("div").show(3000)//显示
        // $("div").fadeOut(2000)//淡出
        // $("div").fadeIn(3000)//淡入
        $("div").slideUp(2000)
        $("div").slideDown(3000)

    </script>
</body>
</html>

渐变:
这里写图片描述
隐藏与显示:
这里写图片描述
淡出与淡入
这里写图片描述
滑动(滑上滑下)
这里写图片描述

3.事件

这里写图片描述

<!DOCTYPE html>
<html lang="en">
<head>
<script src="jquery.js"></script>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <input type="button" value="点我">
    <script>
    //点击
    $("input").click(

            function(){
                document.title="这是标题位置"
            }
        )
    //双击
    $("input").dblclick(

            function(){
                document.title="这是标题位置"
            }
        )

        //鼠标进入
        // $("input").mouseenter(

        //  function(){
        //      document.title="这是标题位置"
        //  }
        // )
        //鼠标滑出
        // $("input").mouseleave(

        //  function(){
        //      document.title="aaa"
        //  }
        // )
    </script>
</body>
</html>

4.方法

这里写图片描述

<!DOCTYPE html>
<html lang="en">
<head>
<style>


</style>
    <script src="jquery.js"></script>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <input type="button" value="1">
    <input type="button" value="2">
    <input type="button" value="3">
    <script>
        //点击位置为1的input(即第二个input)
        $("input:eq(1)").click(
            function(){
                $("input:eq(1)").hide();
                //第一个input消失
                //$("input:first").hide();
                //第二个input消失
                //$("input:last").hide();
            }
            )

    </script>
</body>
</html>

这里写图片描述

5.html操作(捕获【拿】和设置【给】)

这里写图片描述

<!DOCTYPE html>
<html lang="en">
<head>
<script src="jquery.js"></script>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<div>
    <input type="text" value="">
    <input type="button" value="提交">
</div>
<script>
//点击按钮title显示input的value值
$("input:eq(1)").click(
    function(){
        document.title=$("input:eq(0)").val()
    }
    )

</script>

</body>
</html>

点击按钮title显示input的value值

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值