P粉030620591
Follow

After following, you can keep track of his dynamic information in a timely manner

Course notes
  • Courses in the relevant section:Common methods for arrays

    PUSH 在最后边追加 POP删除最后一个 unshift在追前面添加 shift删除最前面的 reverse反转数组 splice(开始索引,多少个,要插入的数据) sort()不传参数 sort(function(a,b){return a-b})把数组重新排序 升序 sort (function(a,b){return b-a})把数组重新排序 降序 join(连接符) 使用连接符把数组链接成字符串 .concat(其他数组)链接其他数组 arr.concat([599,67]) .slice(开始索引,结束索引),截取数组,返回值为新数组 indexOf()查找目标值所在的索引位置,返回索引位置,返回-1表示无此数据 forEach(function(item,index,arr){})没有返回值 map(function(item,index,arr){})映射数组,返回值为映射要的数组 filter(function(item,index,arr){})过滤数组,返回值为过滤好的数组 every(function(item,index,arr){})判断是否每一项否满足条件,返回值为布尔值 some(function(item,index,arr){})判断是否某一项满足条件,返回值为布尔值

    2023-02-050个赞

  • Courses in the relevant section:Common methods for strings

    .charAt(索引)返回值为对应索引位置的字符 .toLowerCase()转换所有为小写 .toUpperCase()转换所有为大写 .replace(换下内容,换上内容) .trim()去除首位空格 .split(分隔符)按照分隔符切割字符串成为数组 .substr(开始索引,多少个) .substring(开始索引,结束索引)包前不包后 .slice(开始索引,结束索引) 以上三个方法返回值均为截取好的字符串

    2023-02-050个赞

  • Courses in the relevant section:Basic DOM operations of javascript (Part 1)

    document.getElementById('id') document.getElementByClassName('元素类名') document.getElementByTagName('标签名') document.querySelector('标签名')-----(‘div’)多个满足条件,只获取满足条件的第一个 ‘.box’ '#abc' document.querySelectorAll('选择器')获取满足所有条件的元素,返回值为为数组。 操作元素内容 文本内容,超文本内容 元素.innerText,获取或插入文本内容 元素.innerHtml,获取或插入超文本内容 操作元素属性 原生属性,标签本身自带的属性,src a 自定义属性 原生属性获取。 操作属性 div标签 var box = document.querySelector('div') var btn = document.querySelector('button') var inp = document.querySelector('input') btn.onclick=function(){ box.id='content' inp.type='checkbox' } 自定义属性 获取:元素.getAttribute('属性名') 设置:元素.setAttribute(‘属性名’,‘属性值’) 删除:元素.removeAttribute('属性名') 以上方法都不用来操作元素类名class,样式style 操作元素类名 元素.className 赋值或获取 操作行内样式类名 元素.style 获取非行内样式 window.getComputedStyle(元素).样式名

    2023-02-050个赞

  • Courses in the relevant section:Basic DOM operations of javascript (Part 2)

    创建节点document.createElement('div')创建一个 插入节点document.appendChild() var span=document.creatElement('span') var div=document.creatElement('div') div.appendChild(span) 在div结构内排在最后面 父节点.insertBefore(要插入的子节点,哪一个子节点的前面) var div=document.querySeletor('div') var p=document.querySeletor('p') var span=document.creatElement('span') div.insertBefor(span,p) 删除节点 1.父节点.removeChild(子节点) 2.节点.remove直接删除节点 替换节点 父节点.replaceChile(换上节点,换下节点) 克隆节点 节点.cloneNode(是否克隆后代节点)false true 获取元素尺寸 元素.offsetHeight 元素.offsetWidth 加上boder 元素.clientHeight 元素.clientWidth

    2023-02-050个赞