Javascript基础知识大纲导图

使用JavaScript控制行为

JavaScript基本语法

  • 语句和注释
  • 变量和数据类型
    • 声明和赋值
    • 简单数据类型和复杂数据类型
    • 变量的命名规则
  • 表达式和运算符
    • 赋值运算符
    • 算术运算符
    • 比较运算符
    • 逻辑运算符
  • 分支结构
    • if…else...
    • switch…case…default...
  • 循环结构
    • for循环
    • while循环
    • do…while循环
  • 数组
    • 创建数组
    • 操作数组中的元素
  • 函数
    • 声明函数
    • 调用函数
    • 参数和返回值
    • 匿名函数
    • 立即调用函数

面向对象

  • 对象的概念
  • 创建对象的字面量语法
  • 访问成员运算符
  • 创建对象的构造函数语法
    • this关键字
  • 添加和删除属性
    • delete关键字
  • 全局对象
    • Number / String / Boolean
    • Date / Math / RegEx / Array

BOM

  • window对象的属性和方法
  • history对象
    • forward() / back() / go()
  • location对象
  • navigator对象
  • screen对象

DOM

  • DOM树
  • 访问元素
    • getElementById() / querySelector()
    • getElementsByClassName() / getElementsByTagName() / querySelectorAll()
    • parentNode / previousSibling / nextSibling / firstChild / lastChild
  • 操作元素
    • nodeValue
    • innerHTML / textContent / createElement() / createTextNode() / appendChild() / removeChild()
    • className / id / hasAttribute() / getAttribute() / setAttribute() / removeAttribute()
  • 事件处理
    • 事件类型
      • UI事件:load / unload / error / resize / scroll
      • 键盘事件:keydown / keyup / keypress
      • 鼠标事件:click / dbclick / mousedown / mouseup / mousemove / mouseover / mouseout
      • 焦点事件:focus / blur
      • 表单事件:input / change / submit / reset / cut / copy / paste / select
    • 事件绑定
      • HTML事件处理程序(不推荐使用,因为要做到标签与代码分离)
      • 传统的DOM事件处理程序(只能附加一个回调函数)
      • 事件监听器(旧的浏览器中不被支持)
    • 事件流:事件捕获 / 事件冒泡
    • 事件对象(低版本IE中的window.event)
      • target(低版本IE中的srcElement)
      • type
      • cancelable
      • preventDefault()
      • stopPropagation()(低版本IE中的cancelBubble)
    • 鼠标事件 - 事件发生的位置
      • 屏幕位置:screenX和screenY
      • 页面位置:pageX和pageY
      • 客户端位置:clientX和clientY
    • 键盘事件 - 哪个键被按下了
      • keyCode属性
      • String.fromCharCode(event.keyCode)
    • HTML5事件
      • DOMContentLoaded
      • hashchange
      • beforeunload

JavaScript API

  • HTML5中的API:geolocation / localStorage / sessionStorage / history

使用jQuery

jQuery概述

  1. Write Less Do More(用更少的代码来完成更多的工作)
  2. 使用CSS选择器来查找元素(更简单更方便)
  3. 使用jQuery方法来操作元素(解决浏览器兼容性问题、应用于所有元素并施加多个方法)

引入jQuery

  • 下载jQuery的开发版和压缩版
  • 从CDN加载jQuery
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script>
    window.jQuery || 
        document.write('<script src="js/jquery-3.3.1.min.js"></script>')
</script>

查找元素

  • 选择器
    • * / element / #id / .class / selector1, selector2
    • ancestor descendant / parent>child / previous+next / previous~siblings
  • 筛选器
    • 基本筛选器::not(selector) / :first / :last / :even / :odd / :eq(index) / :gt(index) / :lt(index) / :animated / :focus
    • 内容筛选器::contains('…') / :empty / :parent / :has(selector)
    • 可见性筛选器::hidden / :visible
    • 子节点筛选器::nth-child(expr) / :first-child / :last-child / :only-child
    • 属性筛选器:[attribute] / [attribute='value'] / [attribute!='value'] / [attribute^='value'] / [attribute$='value'] / [attribute|='value'] / [attribute~='value']
  • 表单::input / :text / :password / :radio / :checkbox / :submit / :image / :reset / :button / :file / :selected / :enabled / :disabled / :checked

执行操作

  • 内容操作
    • 获取/修改内容:html() / text() / replaceWith() / remove()
    • 获取/设置元素:before() / after() / prepend() / append() / remove() / clone() / unwrap() / detach() / empty() / add()
    • 获取/修改属性:attr() / removeAttr() / addClass() / removeClass() / css()
    • 获取/设置表单值:val()
  • 查找操作
    • 查找方法:find() / parent() / children() / siblings() / next() / nextAll() / prev() / prevAll()
    • 筛选器:filter() / not() / has() / is() / contains()
    • 索引编号:eq()
  • 尺寸和位置
    • 尺寸相关:height() / width() / innerHeight() / innerWidth() / outerWidth() / outerHeight()
    • 位置相关:offset() / position() / scrollLeft() / scrollTop()
  • 特效和动画
    • 基本动画:show() / hide() / toggle()
    • 消失出现:fadeIn() / fadeOut() / fadeTo() / fadeToggle()
    • 滑动效果:slideDown() / slideUp() / slideToggle()
    • 自定义:delay() / stop() / animate()
  • 事件
    • 文档加载:ready() / load()
    • 用户交互:on() / off()

链式操作

检测页面是否可用

<script>
    $(document).ready(function() {
        
    });
</script>
<script>
    $(function() {
        
    });
</script>

jQuery插件

  • jQuery Validation
  • jQuery Treeview
  • jQuery Autocomplete
  • jQuery UI

避免和其他库的冲突

先引入其他库再引入jQuery的情况。

<script src="other.js"></script>
<script src="jquery.js"></script>
<script>
	jQuery.noConflict();
    jQuery(function() {
        jQuery('div').hide();
    });
</script>

先引入jQuery再引入其他库的情况。

<script src="jquery.js"></script>
<script src="other.js"></script>
<script>
    jQuery(function() {
        jQuery('div').hide();
    });
</script>

使用Ajax

  • 原生的Ajax
  • 基于jQuery的Ajax
    • 加载内容
    • 提交表单

使用Bootstrap

特点

  1. 支持主流的浏览器和移动设备
  2. 容易上手
  3. 响应式设计

内容

  1. 网格系统
  2. 封装的CSS
  3. 现成的组件
  4. JavaScript插件

猜你喜欢

转载自blog.csdn.net/ZZQHELLO2018/article/details/81142197