jQuery

jQuery基础选择器

层次选择器

索引选择器

内容选择器

可见性选择器

属性选择器

表格列选择器

No.选择器描述返回类型
1:nth-child(eq\even\odd\index)选择制定列中的所有元素,可以使用列的索引,全部偶数索引、全部奇数列索引来完成、需要注意的是:这个列的索引是从1开始元素集合
2:first-child取得表格行的首列元素集合
3:last-child取得表格行的尾列元素集合
4:only-child取得只有一个子元素的父元素元素集合

表单选择器

|NO|选择器|描述|返回类型|
|1|:input|取得所有的输入组件对象。如text、radio|元素组合|
|2|:text|取得所有的文本输入框元素|元素集合|
|3|:password|取得所有的密码输入组件|元素集合|
|4|:radio|取得所有的单选框|元素集合|
|5|:CheckBox|取得所有的复选框|元素集合|
|6|:button|取得所有的按钮|元素集合|
|7|:submit|取得所有的提交按钮|元素集合|
|8|:reset|取得所有的重置按钮|元素集合|
|9|:file|取得所有的上传组件|元素组件|
|10|:image|取得图片按钮|元素集合|
|11|:hidden|取得所有的隐藏域|元素集合|

DOM操作函数

事件选择

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery练习</title>
<script type="text/javascript" src="jquery/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
    $(function() {
        $("button[id^='dept']").each(function(){
            $(this).on("click",function(){
                deptno=this.id.split("-")[1];
                $("#dept-"+deptno).text("新部门-"+deptno);
            });
        });
    })
</script>
</head>
<body>
    <div>
        <span id="dept-1">部门1</span>:
        <button id="dept-1">编辑</button>
        <br> <span id="dept-2">部门2</span>:
        <button id="dept-2">编辑</button>
        <br> <span id="dept-3">部门3</span>:
        <button id="dept-3">编辑</button>
        <br>
    </div>
</body>
</html>

Ajax处理

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery练习</title>
<script type="text/javascript" src="jquery/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
    /*
    $(function() {
        $(sendBut).on("click",function(){
            $.ajax({//这里面需要将所有要发送的数据以JSON的形式发送
                url : "echo",
                method : "post",
                data : {
                    name : "hello",
                    msg : "你好"
                },
                dataType : "text" ,
                success : function(){
                    console.log("操作处理成功," );
                },
                error : function(){
                    console.log("操作失败");
                },
            });
        });
    })
     */
    $(function() {
        $(sendBut).on("click", function() {
            $.get("echo", {
                name : "hello",
                msg : "你好"
            }, function(data) {
                console.log(data);
            }, "text");
        });
    })
</script>
</head>
<body>
    <div id="myDiv"></div>
    <button id="sendBut">回应</button>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值