前端

内容回顾:

  -BOM

  -jquery介绍

  -jquery下载和引入方式

    npm install jquery  

  -jquery的选择器

    -基本选择器

      -通配符选择器

      - id选择器

      - 类选择器

      - 标签选择器

    - 高级选择器

      - 后代  空格表示

      -子代  >

      - 毗邻兄弟  +

      - 兄弟      ~

      -  组合选择器   div,p,a

      -  交集选择器   div,active

      -  属性选择器   $('input[type="text"]')

    -  jquery的动画效果

      - 普通动画

        先要停掉动画 stop()

         - show(3000,fn)

         -  hide()

         -  toggle(3000,fn)

      -   卷帘门效果

           -  slideDown()

           -  slideUp()

           -  slideToggle()

      -   淡入淡出

           -  fadeIn()

           -  fadeOut()

         -  fadeToggle()

    - jquery和js对象转换

      js===>jquery

      $(jsDOM对象)

      jquery==>jsDOM对象

        $('div')[0]

        $('div').get(0)

今日内容:

<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery.js"></script>
<style> li:nth-child(3){
background: deeppink;
}
</style> </head>
<body> <ul>
<li class="item1">alex</li>
<li class="item1">得劲</li>
<li class="item1">裤架为</li>
<li class="item1">王家辉</li>
</ul>
<input type="text">
<input type="radio" checked name="sex" value="1">男
<input type="radio" name="sex" value="0">女
<select name="" id="">
<option value="smoke" >抽烟</option>
<option value="drink">喝酒</option>
<option value="tangtou" selected>烫头</option>
<option value="koufoot">抠脚</option>
</select> <button>提交</button> <script> //ajax
//筛选选择器
$('ul li:eq(3)').css('color','yellow');//eq从0开始选择
$('ul li:first').css('color','red');
$('ul li:last').css('color','red');
$('ul li:nth-child(4)').css('background','yellow');//从1开始选择 // console.log($('input[type=radio]:checked'));
// console.log($('select option:selected').text()); $('button').click(function () {
console.log($('input[type=radio]:checked'));
})
</script>
</body>

  -补充选择器(筛选选择器,筛选的方法)

    -筛选选择器

      -eq()  获取匹配的元素  索引从0开始

      -first()

      -last()

      -属性选择器$('ul li:nth-child(4)')

      -$('input [type=radio]:checked')  获取选中的单选的元素

      -$('select option:selected').text()  获取下拉框被选中的元素

<body>

    <ul>
<li class="item1">
<a href="javascript:void(0);">alex</a>
<ol>
<li>小茹</li>
</ol>
</li>
<li class="item2">
<p class="active">得劲</p>
</li>
<li class="item3">裤架为</li>
<li class="item4">王家辉</li>
</ul> <script>
//find(selector)
console.log($('ul').find('li.item1 a').css('color','red')) //链式编程
$('ul').find('li.item1 a').css('color','red').click(function () {
//html() 如果没有参数,表示获取值,如果有一个参数,表示设置值
alert($(this).html()); console.log($(this).html('黄文泰'));
$(this).html('黄文泰').css({'color':'yellow'}) }); console.log($('ul').find('*')); //获取的是亲儿子们
console.log($('ul').children()); // $('ul li:eq(3)')
console.log($('ul li').eq(3)) //获取的是亲爹爹
console.log( $('p.active').parent()) console.log( $('.item1').siblings('.item2'));
</script>

- 筛选的方法
            - $('ul').find('li.active') 查找后代(儿子和孙子。。。。)元素
            - children() 查找亲儿子
            - eq() 获取指定的元素 索引从0 开始
            - parent() 获取亲爹
            - siblings() 选取兄弟(除它本身之外)

<script src="jquery.js"></script>
<style>
*{
padding: 0;
margin: 0;
}
ul{
list-style: none;
} div.box{
width: 600px;
height: 600px; }
ul{
overflow: hidden;
}
ul li {
float: left;
width: 194px;
height: 80px;
line-height: 80px;
text-align: center;
background-color: red;
border: 1px solid darkgoldenrod;
font-size: 18px;
color: #fff;
font-weight: 700;
}
ul li a{
display: block;
width: 194px;
height: 80px;
text-decoration: none;
color: #fff; }
ul li a.active{
background-color: green;
} div.box p{
width: 594px;
height: 300px;
line-height: 300px;
text-align: center;
color: #fff;
font-weight: bolder;
background-color: darkred;
display: none;
}
div.box p.active{
display: block;
} </style> </head>
<body>
<div class="box">
<ul>
<li>
<a href="javascript:void(0)">新闻</a>
</li>
<li>
<a href="javascript:void(0);">音乐</a>
</li>
<li>
<a href="javascript:void(0);">体育</a>
</li>
</ul>
<p>新闻</p>
<p>音乐</p>
<p>体育</p>
</div> <script>
       $('ul li a').click(function () {
$(this).addClass('active').parent().siblings('li').find('a').removeClass('active');
let index = $(this).parent().index();
console.log(index);
$('.box p').eq(index).addClass('active').siblings('p').removeClass('active');
})
</script>
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery.js"></script>
<style>
*{
padding: 0;
margin: 0;
}
ul{
list-style: none;
} div.box{
width: 600px;
height: 600px; }
ul{
overflow: hidden;
}
ul li {
float: left;
width: 194px;
height: 80px;
line-height: 80px;
text-align: center;
background-color: red;
border: 1px solid darkgoldenrod;
font-size: 18px;
color: #fff;
font-weight: 700;
}
/*ul li {*/
/*display: block;*/
/*width: 194px;*/
/*height: 80px;*/
/*text-decoration: none;*/
/*color: #fff;*/ /*}*/
ul li.active{
background-color: green;
} div.box p{
width: 594px;
height: 300px;
line-height: 300px;
text-align: center;
color: #fff;
font-weight: bolder;
background-color: darkred;
display: none;
}
div.box p.active{
display: block;
} </style> </head>
<body>
<div class="box">
<ul>
<li>新闻</li>
<li>音乐</li>
<li>体育</li>
</ul>
<p>新闻</p>
<p>音乐</p>
<p>体育</p>
</div> <script> $('ul li').click(function () {
console.log($(this).addClass('active')); $(this).addClass('active').siblings('li').removeClass('active'); let index = $(this).index();
$('.box p').eq(index).addClass('active').siblings('p').removeClass('active');
}) </script> </body>
</html>

- jquery自定义动画

   - animate({动画队列属性},时间,fn)

.box{
width: 200px;
height: 200px;
background-color:red;
color: #fff;
position: absolute;
top: 30px;
left: 0;
line-height:200px;
text-align: center; }
</style> </head>
<body>
<button>动画</button>
<div class="box">得劲</div>
<script> //动画 在3秒时间 宽高 400px 变成圆,color:green
$('button').click(function () {
let animate1 = {
"width":'400',
"height":"400",
"border-radius":'200',
"top":"400",
"left":"600", } // animate() 自定义动画
$('.box').animate(animate1,3000,function () {
$(this).hide();
})
})
</script>

音频

<audio src="./Beyond%20-%20情人.mp3" controls></audio>

- jquery的DOM操作
        - 样式操作
           - .css()
        - 对象属性操作
           # 如果有一个参数,表示获取值,两个参数,设置值
            prop()
           # 移除单个值或者多个值,多个值用空格隔开
            removeProp()
        - 标签属性操作
            # 如果有一个参数,表示获取值,两个参数,设置值
            attr()
            # 移除单个值或者多个值,多个值用空格隔开
            removeAttr()
        - 类操作
            - addClass('active xxx bbb ccc')
            - removeClass('active xxx')
            - toggleClass()
           
        - 值的操作
            # 如果没有参数,表示获取值,如果有一个参数,表示设置值
            - text()
            - html()
            - val()

 <style>
.box{
width: 200px;
height: 200px;
background-color:red;
color: #fff;
position: absolute;
top: 30px;
left: 0;
line-height:200px;
text-align: center; }
div.hide{
display: none;
} </style> </head>
<body>
<button>隐藏</button>
<div class="box hide">得劲</div>
<script> $('button').click(function () { $('.box').addClass('hide');
// $('.box').removeClass('aa bb cc');
// $('.box').toggleClass('hide');
})
</script>
</body> <body> <div class="box"> </div>
<input type="text" value="家辉">
<script> // console.log($('.box').text());
// $('.box').text('得劲'); console.log($('.box').html());
$('.box').html('<h2>得劲</h2>'); console.log($('input[type=text]').val());
$('input[type=text]').val('哈哈哈') </script>
</body>
<body>
<audio src="Beyond%20-%20情人.mp3" controls id="21" class="" title=""></audio> <input type="radio" checked>男 <a href="">百度一下</a> <script>
console.log($('audio'));
console.log($('audio').prop('src'));
console.log($('audio').prop('id','mp3')); console.log($('input').prop('checked'));
console.log($('input').attr('checked'));
$('a').attr('href','http://www.baidu.com');
$('a').prop('href','http://www.baiduxxx.com');
$('a').attr('title','http://www.baidu.com'); $('a').removeAttr('href title'); console.log($('a')) </script>

      

day56 Pyhton 前端Jquery08的更多相关文章

  1. day50 Pyhton 前端01

    文档结构: <!-- 定义文档类型 --> <!DOCTYPE html> <!-- 文档 --> <html lang='en'> <!-- 仅 ...

  2. day57 Pyhton 前端Jquery09

    内容回顾: - 筛选选择器 $('li:eq(1)')  查找匹配的元素 $('li:first') $('li:last') - 属性选择器 - 筛选的方法 - find()  查找后代的元素 - ...

  3. day55 Pyhton 前端Jquery07

    昨日回顾: 表单,点击submit提交以后,服务端受到信息 import socket import pymysql from urllib.parse import unquote def run( ...

  4. day54 Pyhton 前端JS06

    内容回顾 - ECMAScript5.0 基础语法 - var 声明变量 - 五种基本数据类型 - string - number NaN number 1 number - boolean - un ...

  5. day54 Pyhton 前端JS05

    今日内容: 1.数组Array var colors = ['red','color','yellow']; 使用new 关键词对构造函数进行创建对象 var colors2 = new Array( ...

  6. day53 Pyhton 前端04

    内容回顾: 盒子: 内边距:padding,解决内部矛盾,内边距的增加整个盒子也会增加 外边距:margin,解决外部矛盾,当来盒子都有外边距的时候,取两者最大值 边框:border border-c ...

  7. day52 Pyhton 前端03

    内容回顾 块级标签: div p h 列表:ol;ul;dl 表格:table 行内标签: span a i/em b/strong u/del 行内块: input textarea img 其他: ...

  8. day51 Pyhton 前端02

    内容回顾: 1.h1~h6:加粗,数字越大级别越小,自动换行 2.br:换行;hr:分割线; (特殊符号,空格) 3.p:与前边和后边内容之间有间距 4.a标签的href:本地文件连接;网络连接;锚链 ...

  9. 最受Web前端开发者欢迎的五大开发工具

    工其事,必利于器.好的开发工具毋容置疑会帮助Web前端开发者事半功倍,51CTO在上期主办的技术沙龙<大型网站PHP开发之道> 对现场的百余位Web开发者做了问卷调查,后经51CTO调研小 ...

随机推荐

  1. 下载安装gradle

    1.登录官网:www.gradle.org,进入到下图的界面: 2.点击Install Gradle,跳转到下一个界面后: 3.下载 4.下载成功后,解压到任意位置,将路径添加到path路径下,选择我 ...

  2. 添加到web.config文件里的用户自定义翻页控件

    <pages> <controls> <add tagPrefix="ucl" tagName="Pager_Backstage" ...

  3. oracle数据处理之sql*loader(二)

    目录 SQL*Loader对不同文件及格式的处理方法 2.1 Excel文件 一般的Excel文件最大行数不超过65536行,说明数据处理量并不大,处理Excel的方式是将其另存为CSV格式文件,然后 ...

  4. 送命题:讲一讲Mybatis插件的原理及如何实现?

    持续原创输出,点击上方蓝字关注我吧 目录 前言 环境配置 什么是插件? 如何自定义插件? 举个栗子 用到哪些注解? 如何注入Mybatis? 测试 插件原理分析 如何生成代理对象? 如何执行? 总结 ...

  5. k8s集群监控(十一)

    Weave Scope   在我之前的docker监控中<Docker容器监控(十)–技术流ken>就已经提到了weave scope. Weave Scope 是 Docker 和 Ku ...

  6. JsonPath使用教程

    application/json标识Json数据格式,是Http请求常见的一种Content-Type.我们经常也会看到接口返回数据类型为json格式.功能测试/自动化脚本里,经常会需要提取json数 ...

  7. python-文本操作和二进制储存

    0x01 open方法 r read w write a append b byte test.txt内容为 yicunyiye wutang 读取test.txt f = open('test.tx ...

  8. Redis学习(四)redis发布订阅

    文章更新时间:2020/04/22 一.简介 Redis 发布订阅(pub/sub)是一种消息通信模式:发送者(pub)发送消息,订阅者(sub)接收消息. Redis 客户端可以订阅任意数量的频道. ...

  9. Spring Cloud实战 | 最终篇:Spring Cloud Gateway+Spring Security OAuth2集成统一认证授权平台下实现注销使JWT失效方案

    一. 前言 在上一篇文章介绍 youlai-mall 项目中,通过整合Spring Cloud Gateway.Spring Security OAuth2.JWT等技术实现了微服务下统一认证授权平台 ...

  10. C# 中的 is 真的是越来越强大,越来越语义化

    一:背景 1. 讲故事 最近发现 C#7 之后的 is 是越来越看不懂了,乍一看花里胡哨的,不过当我静下心来仔细研读,发现这 is 是越来越短小精悍,而且还特别语义化,那怎是一个爽字了得,这一篇就和大 ...