巨蟒python全栈开发数据库前端8:jQuery框架2

本文主要是介绍巨蟒python全栈开发数据库前端8:jQuery框架2,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

数据可视化推荐网站(都是JavaScript写的):

echart网站:

  https://echarts.baidu.com/

聚宽网站:

  https://www.joinquant.com/

我们要多用心也是可以做前端的!!!

 

回顾:

1.jquery介绍

2.jquery的引入方式

3.jquery选择器:找标签

  基本选择器:ID,Class,标签,配合使用,组合选择器,所有元素选择器,

  层级选择器:同css

  基本筛选器:选择之后进行过滤

  属性选择器:

  表单筛选器:

4.筛选器方法(将来用的会很多):下一个元素,上一个元素,父亲元素,儿子和兄弟元素,查找,筛选

5.操作标签:

  样式操作:(样式类)

  位置操作:

  尺寸:

  文本操作:

  属性操作:

  文档处理:

6.转换:jq=>dom   [0]

     dom=>jq $("this")

7.后边的django逻辑性会有很多,需要视频查漏补缺.

 

今日大纲:

1.事件

2.批量操作

3.事件冒泡

4.事件委托

 

详细内容:

1.事件

常用事件

click(function(){...})
hover(function(){...})

blur(function(){...}) focus(function(){...}) change(function(){...})
//内容发生变化,input,select等
keyup(function(){...}) mouseover 和 mouseenter的区别是:mouseover事件只要你在绑定该事件的对象上移动就会一直触发,mmouseenter事件只触发一次,表示鼠标进入这个对象

第一种绑定事件的方法: click

代码:

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title>
</head>
<body><button id="btn1">点我啊</button><!--1.button按钮--><script src="jquery-3.3.1.min.js"></script><!--2.引入js包--><script>$('#btn1').click(function () {alert('999');})//3.弹窗</script>
</body>
</html>

测试结果:点击"点我啊",弹出下面的对话框

 第二种绑定事件的方法(on):

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title>
</head>
<body><button id="btn1">点我啊</button><!--1.button按钮--><script src="jquery-3.3.1.min.js"></script><!--2.引入js包--><script>// $('#btn1').click(function () {//     alert('999');// })//3.弹窗
        $('#btn1').on('click',function () {alert('777');})//    第二种绑定事件的方法</script>
</body>
</html>

 

 测试结果:点击"点我啊",弹出下面的对话框

hover指的是,鼠标移动上去,这个事件.

 代码:测试的是hover  div标签,class值为d1

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title>
    <style>.d1{background-color: red;width: 100px;height: 100px;}</style>
</head>
<body><div class="d1"></div><button id="btn1">点我啊</button><!--1.button按钮--><script src="jquery-3.3.1.min.js"></script><!--2.引入js包--><script>// $('#btn1').click(function () {//     alert('999');// })//3.弹窗
        $('#btn1').on('click',function () {alert('777');})//    第二种绑定事件的方法
        $('.d1').hover(function () {console.log('111');})</script>
</body>
</html>

 

测试结果:鼠标每移动上去一次,下边就加一次

鼠标移动到div上,变为绿色,移动下来变成红色

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>.d1{background-color: red;width: 100px;height: 100px;}</style>
</head>
<body><div class="d1"></div><button id="btn1">点我啊</button><!--1.button按钮--><script src="jquery-3.3.1.min.js"></script><!--2.引入js包--><script>// $('#btn1').click(function () {//     alert('999');// })//3.弹窗
        $('#btn1').on('click',function () {alert('777');})//    第二种绑定事件的方法
        $('.d1').hover(function () {// console.log('111');
            $(this).css('background-color','green')//    鼠标移动上去就改变为绿颜色
            },function () {$(this).css('background-color','red')//鼠标移动下来颜色颜色改变为红色
            })</script>
</body>
</html>

 focus焦点事件&blur事件:

代码案例:

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>.d1{background-color: red;width: 100px;height: 100px;}</style>
</head>
<body><div class="d1"></div><input id="i1" type="text"><!--input获取焦点--><button id="btn1">点我啊</button><!--1.button按钮--><script src="jquery-3.3.1.min.js"></script><!--2.引入js包--><script>// $('#btn1').click(function () {//     alert('999');// })//3.弹窗
        $('#btn1').on('click',function () {alert('777');});//    第二种绑定事件的方法
        $('.d1').hover(function () {// console.log('111');
            $(this).css('background-color','green')//    鼠标移动上去就改变为绿颜色
            },function () {$(this).css('background-color','red')//鼠标移动下来颜色颜色改变为红色
            });$("#i1").focus(function () {$(this).css('background-color','red');//    鼠标移动到input框上去点击,变成红色
        })$("#i1").blur(function () {$(this).css('background-color','green');//    鼠标移动到input框下来点击,变成绿色
        })</script>
</body>
</html>

change事件:

html代码:选择框内发生改变,输入框的颜色发生变化

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>.d1{background-color: red;width: 100px;height: 100px;}</style>
</head>
<body><div class="d1"></div><input id="i1" type="text"><!--input获取焦点--><select name="" id="s1"><option value="1">11</option><option value="2">22</option><option value="3">33</option>
</select><button id="btn1">点我啊</button><!--1.button按钮--><script src="jquery-3.3.1.min.js"></script><!--2.引入js包--><script>// $('#btn1').click(function () {//     alert('999');// })//3.弹窗
        $('#btn1').on('click',function () {alert('777');});//    第二种绑定事件的方法
        $('.d1').hover(function () {// console.log('111');
            $(this).css('background-color','green')//    鼠标移动上去就改变为绿颜色
            },function () {$(this).css('background-color','red')//鼠标移动下来颜色颜色改变为红色
            });$("#i1").focus(function () {$(this).css('background-color','red');//    鼠标移动到input框上去点击,变成红色
        });$("#i1").blur(function () {$(this).css('background-color','green');//    鼠标移动到input框下来点击,变成绿色
        });$("#s1").change(function () {$("#i1").css('background-color','blue');})</script>
</body>
</html>

keyup&keydown事件(键盘上按下来)

 //e,event代表事件

 

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>.d1{background-color: red;width: 100px;height: 100px;}</style>
</head>
<body><div class="d1"></div><input id="i1" type="text"><!--input获取焦点--><select name="" id="s1"><option value="1">11</option><option value="2">22</option><option value="3">33</option>
</select><button id="btn1">点我啊</button><!--1.button按钮--><script src="jquery-3.3.1.min.js"></script><!--2.引入js包--><script>// $('#btn1').click(function () {//     alert('999');// })//3.弹窗
        $('#btn1').on('click',function () {alert('777');});//    第二种绑定事件的方法
        $('.d1').hover(function () {// console.log('111');
            $(this).css('background-color','green')//    鼠标移动上去就改变为绿颜色
            },function () {$(this).css('background-color','red')//鼠标移动下来颜色颜色改变为红色
            });$("#i1").focus(function () {$(this).css('background-color','red');//    鼠标移动到input框上去点击,变成红色
        });$("#i1").blur(function () {$(this).css('background-color','green');//    鼠标移动到input框下来点击,变成绿色
        });$("#s1").change(function () {$("#i1").css('background-color','blue');});$(window).keydown(function (e) {console.log(e.keyCode);})</script>
</body>
</html>

 

鼠标点击在页面上,再在键盘上输入字母等,显示数字,推测应该显示的是ascii码.

#shift键表示16,时刻监控着键盘,同上边一样

这个e或者event表示鼠标按下或者抬起这个事件的本身.

在键盘上按下,或者抬起

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>.d1{background-color: red;width: 100px;height: 100px;}</style>
</head>
<body><div class="d1"></div><input id="i1" type="text"><!--input获取焦点--><select name="" id="s1"><option value="1">11</option><option value="2">22</option><option value="3">33</option>
</select><button id="btn1">点我啊</button><!--1.button按钮--><script src="jquery-3.3.1.min.js"></script><!--2.引入js包--><script>// $('#btn1').click(function () {//     alert('999');// })//3.弹窗
        $('#btn1').on('click',function () {alert('777');});//    第二种绑定事件的方法
        $('.d1').hover(function () {// console.log('111');
            $(this).css('background-color','green')//    鼠标移动上去就改变为绿颜色
            },function () {$(this).css('background-color','red')//鼠标移动下来颜色颜色改变为红色
            });$("#i1").focus(function () {$(this).css('background-color','red');//    鼠标移动到input框上去点击,变成红色
        });$("#i1").blur(function () {$(this).css('background-color','green');//    鼠标移动到input框下来点击,变成绿色
        });$("#s1").change(function () {$("#i1").css('background-color','blue');}); $(window).keydown(function (e) {// console.log(e.keyCode);if(e.keyCode===16){console.log('这是shift键')//    鼠标按在shift键上会显示这个
            }})</script>
</body>
</html>

mouseover表示鼠标每次从外边移动进去,则加1,

mouseenter

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>.d1,#d2{background-color: red;width: 100px;height: 100px;}</style>
</head>
<body><div class="d1"></div><input id="i1" type="text"><!--input获取焦点--><select name="" id="s1"><option value="1">11</option><option value="2">22</option><option value="3">33</option>
</select>
<div id="d2"></div><button id="btn1">点我啊</button><!--1.button按钮--><script src="jquery-3.3.1.min.js"></script><!--2.引入js包--><script>// $('#btn1').click(function () {//     alert('999');// })//3.弹窗
        $('#btn1').on('click',function () {alert('777');});//    第二种绑定事件的方法
        $('.d1').hover(function () {// console.log('111');
            $(this).css('background-color','green')//    鼠标移动上去就改变为绿颜色
            },function () {$(this).css('background-color','red')//鼠标移动下来颜色颜色改变为红色
            });$("#i1").focus(function () {$(this).css('background-color','red');//    鼠标移动到input框上去点击,变成红色
        });$("#i1").blur(function () {$(this).css('background-color','green');//    鼠标移动到input框下来点击,变成绿色
        });$("#s1").change(function () {$("#i1").css('background-color','blue');});$(window).keyup(function (e) {// console.log(e.keyCode);if(e.keyCode===16){console.log('这是shift键')//    鼠标按在shift键上会显示这个
            }}); $('#d2').mouseover(function () {console.log('xxx');//    应该是在框内移动,就打印,实际情况是在每次进入才打印
        });// $('#d2').mouseenter(function () {//     console.log('xxx');//    每次进入打印一次.// });</script>
</body>
</html>

 参考菜鸟教程:(讲解有误)

 

注意:hover事件不可以通过on进行绑定.

 

事件绑定:

移除事件(不常用):

组织后续时间执行:

 

2.批量操作

当选中某个操作,按住shift,可以一起操作某个事件.

批量操作可以理解成,对一些事物,处理相同的操作的一个程序

3.事件冒泡:

事件冒泡可以理解为,触发了子事件,父事件也会跟着触发.

 代码:

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>#d2{height: 100px;width:100px;background-color: green;}</style></head>
<body><div id="d1"><div id="d2"></div>
</div><script src="jquery-3.3.1.min.js"></script>
<script>$("#d1").click(function () {alert('父级标签')});$("#d2").click(function () {alert('子级标签')});
</script>
</body>
</html>

 

点击绿框:

阻止冒泡发生的方法:两种

 

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>#d2{height: 100px;width:100px;background-color: green;}</style></head>
<body><div id="d1"><div id="d2"></div>
</div><script src="jquery-3.3.1.min.js"></script>
<script>$("#d1").click(function () {alert('父级标签')}); $("#d2").click(function (e) {alert('子级标签')// return false;
        e.stopPropagation()
    //下面这个方法必须加上e事件.
});
</script> </body> </html>

 

4.事件委托:

事件委托是通过事件冒泡的原理,利用父标签去捕获子标签的事件,将未来添加进来的某些子标签自动绑定上事件.

以全选,取消,反选例子为基础来进行验证事件委托.

 

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title>
</head>
<body><button id="all">全选</button>
<button id="reverse">反选</button>
<button id="cancel">取消</button>
<table border="1"><thead><tr><th>#</th><th>姓名</th><th>爱好</th></tr></thead><tbody><tr><td><input type="checkbox"></td><td>金老板</td><td>开车</td></tr><tr><td><input type="checkbox"></td><td>景女神</td><td>茶道</td></tr><tr><td><input type="checkbox"></td><td>苑昊(苑局)</td><td>不洗头、不翻车、不要脸</td></tr></tbody>
</table><!--<script src="jquery.js"></script>-->
<script src="jquery-3.3.1.min.js"></script>
<script>// 点击全选按钮 选中所有的checkbox// DOM绑定事件方法// $("#all")[0].onclick = function(){}// jQuery绑定事件方法
    $("#all").click(function () {$(":checkbox").prop('checked', true);});// 取消
    $("#cancel").on("click", function () {$(":checkbox").prop('checked', false);});// 反选
    $("#reverse").click(function () {// 1. 找到所有选中的checkbox取消选中// $("input:checked").prop('checked', false);// // 2. 找到没有选中的checkbox选中// $("input:not(:checked)").prop('checked', true);//你会发现上面这么写,不行,为什么呢?因为你做了第一步操作之后,再做第二步操作的时候,所有标签就已经全部取消选中了,所以第二步就把所有标签选中了// 方法1. for循环所有的checkbox,挨个判断原来选中就取消选中,原来没选中就选中var $checkbox = $(":checkbox");for (var i=0;i<$checkbox.length;i++){// 获取原来的选中与否的状态var status = $($checkbox[i]).prop('checked');$($checkbox[i]).prop('checked', !status);}// 方法2. 先用变量把标签原来的状态保存下来//     var $unchecked =  $("input:not(:checked)");//     var $checked = $("input:checked");//
    //     $unchecked.prop('checked', true);//     $checked.prop('checked', false);
    })</script>
</body>
</html>

 通过删除引出,委托事件:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><style>.shadow{position: fixed;background-color: rgba(0,0,0,0.3);top:0;left:0;bottom:0;right:0;/*设置上下左右没有距离*/z-index: 900;}.modal{position: fixed;width: 400px;height: 200px;background-color: #ffffff;top:50%;left:50%;z-index: 1000;margin-top: -100px;/*往上移动*/margin-left: -200px;/*往左移动*/}.hide{display:none;/*隐藏*/}</style>
</head>
<body><button id="all">全选</button>
<button id="reverse">反选</button>
<button id="cancel">取消</button>
<button id="add">增加</button>
<table border="1"><thead><tr><th>#</th><th>姓名</th><th>爱好</th><th>操作</th></tr></thead><tbody><tr><td><input type="checkbox"></td><td>金老板</td><td>开车</td><td><button class="b1">删除</button></td></tr><tr><td><input type="checkbox"></td><td>景女神</td><td>茶道</td><td><button class="b1">删除</button></td></tr><tr><td><input type="checkbox"></td><td>苑昊(苑局)</td><td>不洗头、不翻车、不要脸</td><td><button class="b1">删除</button></td></tr></tbody>
</table><div class="modal hide"><!--对话框开始的时候隐藏--><div><label for="name">姓名</label><input id="name" type="text"></div><div><label for="hobby">爱好</label><input id="hobby" type="text"></div><div><button class="btn2">保存</button></div>
</div><div class="shadow hide"></div>
<!--阴影层开始的时候隐藏--><!--<script src="jquery.js"></script>-->
<script src="jquery-3.3.1.min.js"></script>
<script>// 点击全选按钮 选中所有的checkbox// DOM绑定事件方法// $("#all")[0].onclick = function(){}// jQuery绑定事件方法
    $("#all").click(function () {$(":checkbox").prop('checked', true);});// 取消
    $("#cancel").on("click", function () {$(":checkbox").prop('checked', false);});// 反选
    $("#reverse").click(function () {// 1. 找到所有选中的checkbox取消选中// $("input:checked").prop('checked', false);// // 2. 找到没有选中的checkbox选中// $("input:not(:checked)").prop('checked', true);//你会发现上面这么写,不行,为什么呢?因为你做了第一步操作之后,再做第二步操作的时候,所有标签就已经全部取消选中了,所以第二步就把所有标签选中了// 方法1. for循环所有的checkbox,挨个判断原来选中就取消选中,原来没选中就选中var $checkbox = $(":checkbox");for (var i=0;i<$checkbox.length;i++){// 获取原来的选中与否的状态var status = $($checkbox[i]).prop('checked');$($checkbox[i]).prop('checked', !status);}// 方法2. 先用变量把标签原来的状态保存下来//     var $unchecked =  $("input:not(:checked)");//     var $checked = $("input:checked");//
    //     $unchecked.prop('checked', true);//     $checked.prop('checked', false);
    })//点击增加,弹出模态框
    $("#add").click(function () {// $(".modal").removeClass('hide');// $(".shadow").removeClass('hide');//整合上边的两条
        $(".modal,.shadow").removeClass('hide');})$('.btn2').click(function () {//1.获取用户输入的信息var name=$('#name').val();var hobby=$('#hobby').val();//2.创建标签,将数据添加到标签里面,拼接字符串添加标签var s="<tr>" +"<td><input type=\"checkbox\"></td>" +"<td>"+name+"</td>" +"<td>"+hobby+"</td>" +"<td><button class=\"b1\">删除</button></td>" +"</tr>";//在上边将要添加的name和hobby添加进去//3.将创建好的标签,天际到表格里面去
        $('tbody').append(s)//添加完成之后//4.关闭(隐藏)对话框
        $('.modal,.shadow').addClass('hide');//    5.清空用户输入的内容
        $('#name').val('');$('#hobby').val('');})//删除按钮事件// $('.b1').click(function () {//     $(this).parent().parent().remove();// //    通过单击button按钮,实现删除功能// })//问题:新增加的,无法绑定删除功能?应该怎么处理
//    1.将删除功能放在最后是不可行的
//    2.需要处理添加这个标签的父标签进行处理,也就是子标签委托父标签处理这个事情。//    注意由上边的.b1标签改写成tbody下的tr标签,//    给下边的tbody下的tr绑定一个click事件,click事件由button触发//    也就是把button事件的处理过程给了他的父亲.//    在这里表示把含有.b1标签的全部委托给它的父亲//
    //事件委托,将button的click事件委托给了祖父tbody标签,实现的效果就是点击button按钮,触发tbody的click事件,$(this表示的还是被点击的那个标签)//on可以做事件委托,单纯的click不可以做事件委托//参数:click事件名称,button委托人,tbody的后代标签
    $('tbody').on('click','button',function () {$(this).parent().parent().remove();})
</script>
</body>
</html>

 5.页面加载

案例1:

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>.d1{background-color: red;width: 100px;height: 100px;}</style></head>
<body><div class="d1"></div>
<script src="jquery-3.3.1.min.js"></script>
<script>$('.d1').click(function () {alert('xxx');})
</script>
</body>
</html>

点击红色区域出现如下对话框.

通过window.onload实现最后加载.在头部放这个

案例:

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>.d1{background-color: red;width: 100px;height: 100px;}</style><script>window.onload=function () {$('.d1').click(function () {alert('xxx');})}</script>
</head>
<body><div class="d1"></div>
<script src="jquery-3.3.1.min.js"></script></body>
</html>

缺点分析:有两个js文件也就是多人操作中,js写在html和js文件中

 html中代码:

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>.d1{background-color: red;width: 100px;height: 100px;}</style><script>window.onload=function () {$('.d1').click(function () {alert('xxx');})}</script><script src="01test.js"></script>
</head>
<body><div class="d1"></div>
<script src="jquery-3.3.1.min.js"></script></body>
</html>

js代码:

window.οnlοad=function () {console.log('aaaaa');
};

 

此时只能在调试框中显示:aaaaa

 

更优化的方法:(两个都能够打印出来了)

 

html代码:

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>.d1{background-color: red;width: 100px;height: 100px;}</style><script src="jquery-3.3.1.min.js"></script><script>// window.οnlοad=function () {//     $('.d1').click(function () {//     alert('xxx');// })// }
     
      //jquery页面加载完成之后做某些事情的操作 $(function () {$('.d1').click(function () {alert('xxx');})})</script><script src="01test.js"></script> </head> <body><div class="d1"></div></body> </html>

js代码(01test.js):

$(function () {console.log('aaaaa');
});

 

结果如下:

 6.动画效果

代码html:

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title><style>.d1{background-color: red;width: 100px;height: 100px;display: none;}</style>
</head>
<body><div class="d1"></div>
</body>
<script src="jquery-3.3.1.min.js"></script>
</html>

 

动画效果案例html2:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><style>.c1{background-color: red;/*background: url("hlw.png") no-repeat;*/width: 200px;height: 200px;/*position: absolute;*/  /*自己试以下position:absolute的效果*/display: none;}.c2{height: 100px;background-color: lawngreen;}</style>
</head>
<body><!--<div class="c1" hidden></div>-->  <!--不用hidden,上面写display:none也是可以的-->
<div class="c1"></div>
<div class="c2"></div>
<script src="jquery-3.3.1.min.js"></script>
<script>// $('.c1').hide(3000);
    $('.c1').show(3000);</script>
</body>
</html>

点赞html案例:

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><title>点赞动画示例</title><style>div {position: relative;display: inline-block;}div>i {display: inline-block;color: red;position: absolute;right: -16px;top: -5px;opacity: 1;}</style>
</head>
<body><div id="d1">点赞</div>
<script src="jquery-3.2.1.min.js"></script>
<script>$("#d1").on("click", function () {var newI = document.createElement("i");newI.innerText = "+1";$(this).append(newI);$(this).children("i").animate({opacity: 0  //1秒之后透明度变为0,注意写法,animate({属性:值},毫秒数) 
    }, 1000)})
</script>
</body>
</html>

 推荐:iconfonts,阿里图标库

 7.其他

测试:

each还可以测试循环所有标签.

 html测试代码:

 

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title></head>
<body>
<ul><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li>
</ul>
<script src="jquery-3.3.1.min.js"></script>
</body>
</html>

 

测试结果:

 

 

 

代码截图 

 

 

 

 

 

 

 

8.

 标签内部也可以存储数据

 9.自定义插件

10.input事件

代码:

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta http-equiv="content-Type" charset="UTF-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>Title</title>
</head>
<body>
<input id="name" type="text">
<script src="jquery-3.3.1.min.js"></script>
<script>$('#name').on('input',function(){console.log($(this).val());})
</script>
</body>
</html>

 

 

转载于:https://www.cnblogs.com/studybrother/p/10394803.html

这篇关于巨蟒python全栈开发数据库前端8:jQuery框架2的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/756904

相关文章

Python调用Orator ORM进行数据库操作

《Python调用OratorORM进行数据库操作》OratorORM是一个功能丰富且灵活的PythonORM库,旨在简化数据库操作,它支持多种数据库并提供了简洁且直观的API,下面我们就... 目录Orator ORM 主要特点安装使用示例总结Orator ORM 是一个功能丰富且灵活的 python O

Python使用国内镜像加速pip安装的方法讲解

《Python使用国内镜像加速pip安装的方法讲解》在Python开发中,pip是一个非常重要的工具,用于安装和管理Python的第三方库,然而,在国内使用pip安装依赖时,往往会因为网络问题而导致速... 目录一、pip 工具简介1. 什么是 pip?2. 什么是 -i 参数?二、国内镜像源的选择三、如何

部署Vue项目到服务器后404错误的原因及解决方案

《部署Vue项目到服务器后404错误的原因及解决方案》文章介绍了Vue项目部署步骤以及404错误的解决方案,部署步骤包括构建项目、上传文件、配置Web服务器、重启Nginx和访问域名,404错误通常是... 目录一、vue项目部署步骤二、404错误原因及解决方案错误场景原因分析解决方案一、Vue项目部署步骤

python使用fastapi实现多语言国际化的操作指南

《python使用fastapi实现多语言国际化的操作指南》本文介绍了使用Python和FastAPI实现多语言国际化的操作指南,包括多语言架构技术栈、翻译管理、前端本地化、语言切换机制以及常见陷阱和... 目录多语言国际化实现指南项目多语言架构技术栈目录结构翻译工作流1. 翻译数据存储2. 翻译生成脚本

Android 悬浮窗开发示例((动态权限请求 | 前台服务和通知 | 悬浮窗创建 )

《Android悬浮窗开发示例((动态权限请求|前台服务和通知|悬浮窗创建)》本文介绍了Android悬浮窗的实现效果,包括动态权限请求、前台服务和通知的使用,悬浮窗权限需要动态申请并引导... 目录一、悬浮窗 动态权限请求1、动态请求权限2、悬浮窗权限说明3、检查动态权限4、申请动态权限5、权限设置完毕后

如何通过Python实现一个消息队列

《如何通过Python实现一个消息队列》这篇文章主要为大家详细介绍了如何通过Python实现一个简单的消息队列,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录如何通过 python 实现消息队列如何把 http 请求放在队列中执行1. 使用 queue.Queue 和 reque

Python如何实现PDF隐私信息检测

《Python如何实现PDF隐私信息检测》随着越来越多的个人信息以电子形式存储和传输,确保这些信息的安全至关重要,本文将介绍如何使用Python检测PDF文件中的隐私信息,需要的可以参考下... 目录项目背景技术栈代码解析功能说明运行结php果在当今,数据隐私保护变得尤为重要。随着越来越多的个人信息以电子形

使用 sql-research-assistant进行 SQL 数据库研究的实战指南(代码实现演示)

《使用sql-research-assistant进行SQL数据库研究的实战指南(代码实现演示)》本文介绍了sql-research-assistant工具,该工具基于LangChain框架,集... 目录技术背景介绍核心原理解析代码实现演示安装和配置项目集成LangSmith 配置(可选)启动服务应用场景

使用Python快速实现链接转word文档

《使用Python快速实现链接转word文档》这篇文章主要为大家详细介绍了如何使用Python快速实现链接转word文档功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 演示代码展示from newspaper import Articlefrom docx import

前端原生js实现拖拽排课效果实例

《前端原生js实现拖拽排课效果实例》:本文主要介绍如何实现一个简单的课程表拖拽功能,通过HTML、CSS和JavaScript的配合,我们实现了课程项的拖拽、放置和显示功能,文中通过实例代码介绍的... 目录1. 效果展示2. 效果分析2.1 关键点2.2 实现方法3. 代码实现3.1 html部分3.2