posts - 139,comments - 1,views - 38143

随笔分类 -  js备忘录

indexOf 和 LastIndexOf
摘要:<script> //首次出现o的下标索引位置 console.log("helloIndexof".indexOf("o")) //最后一次出现o的下标索引位置 console.log("helloIndexof".lastIndexOf("o")) //在数组中首次出现的下标索引位置 let l 阅读全文
posted @ 2022-11-01 19:24 最帅爸爸 阅读(17) 评论(0) 推荐(0) 编辑
深拷贝的几种方法
摘要:一:递归调用 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" cont 阅读全文
posted @ 2022-10-26 08:53 最帅爸爸 阅读(69) 评论(0) 推荐(0) 编辑
prompt
摘要:prompt()方法用于弹出框,并且附带一个文本输入框 alert("请猜测一个1-100之间的数") var a = Math.floor(Math.random() * 100); alert(a); while(1){ var c =(prompt("请输入数字")); if (c == a) 阅读全文
posted @ 2022-09-25 14:56 最帅爸爸 阅读(174) 评论(0) 推荐(0) 编辑
标题,ico动态化
摘要://获取ico元素 var link = document.querySelector("link[rel*='icon']"); link.href = "image/public/" +??? //直接动态绑定标题 document.title = ??? 阅读全文
posted @ 2022-09-21 20:04 最帅爸爸 阅读(32) 评论(0) 推荐(0) 编辑
js移除style样式
摘要:removeAttribute() 例: <button @click="edit" type="button" disabled id="btnsubmit">保存</button> let btnadd=document.getElementById("btnadd");btnadd.remov 阅读全文
posted @ 2022-09-20 17:46 最帅爸爸 阅读(575) 评论(0) 推荐(0) 编辑
js模块化开发
摘要:外部js文件 function a(a,b) { console.log(a+b);} 导出:module.exports ={a}; 引用: import {a} from (路径); 阅读全文
posted @ 2022-09-17 20:48 最帅爸爸 阅读(18) 评论(0) 推荐(0) 编辑
时间戳转换器
摘要:function date(date) { var date = new Date(date * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000 var Y = date.getFullYear() + '-'; var M = (date.getMonth()+1 < 阅读全文
posted @ 2022-09-17 20:38 最帅爸爸 阅读(178) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示