JavaScript
文章平均质量分 63
番茄粥
这个作者很懒,什么都没留下…
展开
-
JS的Web Storage和Cookie
JS的Web StorageWeb Storage 将少量的数据储存于客户端中,分为localStorage和sessionStoragelocalStorage 可应用于同一网站/网页的可跨窗口和分页sessionStorage 只对当前网页有效,关闭浏览器窗口后数据已丢失cookie 在本地存储数据,起初用于客户端和服务端进行会话时使用,只能存储数据量较小的数据4KB,主要实现对前端数据的增删读操作。每个cookie都是以键值对的形式保存的,即key=value的格式。各个cookie之间一般原创 2021-04-30 17:20:43 · 136 阅读 · 1 评论 -
JS的返回top操作
JS的返回top操作“返回顶部”实现是隐藏的,当滚动到一定高度时显示,点击后回到页面顶部top=0位置<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>DOM</title> <style> body{height: 1000px;} #Totop{ hei原创 2021-04-29 20:31:01 · 1619 阅读 · 0 评论 -
DOM节点增删替克隆操作
DOM操作<body><ul> <p>text</p> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li></ul><script>let ul原创 2021-04-29 20:21:32 · 72 阅读 · 0 评论 -
JS的字符串操作
JS的字符串操作全部大写 toUpperCase();var str = "To the world you may be one person, but to one person you may be the world . ";console.log( str.toUpperCase() );全部小写 toLowerCase()console.log( str.toLowerCase() );去除空格 trim()console.log( str.trim() );原创 2021-04-28 21:53:45 · 81 阅读 · 0 评论 -
JS的数组操作
JS的数组操作var arr = [1,2,3,4,5,6,7,8,9];// 判断数组的类型 typeof —— Objectconsole.log(typeof arr);// 数组的遍历 forEach// value 每一项元素的值,index 数组的索引arr.forEach(function (value,index){ console.log(index+" "+value);});// 数组元素的增加arr.push(num); //在数组末端添加一个或者原创 2021-04-28 21:22:24 · 385 阅读 · 0 评论 -
JS的定时器
JS的定时器setInterval和setTimeoutsetTimeout():延时定时器,指定延长多长时间后去执行,只执行一次。setTimeout(foo,2000):2秒后去调用foo函数setInterval():连续的定时器,通过设定一定的时间间隔去执行代码。setInterval(foo,1000):每隔1s去调用foo函数。clearInterval(timer)/clearTimeout(timer):清除定时器现在做两个例子,一个是获取指定时间的倒计时,另一个是发送验证码获原创 2021-04-28 16:29:02 · 171 阅读 · 0 评论