diff --git "a/19 \351\231\210\345\246\203/20231214\344\275\234\344\270\232.md" "b/19 \351\231\210\345\246\203/20231214\344\275\234\344\270\232.md" new file mode 100644 index 0000000000000000000000000000000000000000..cf5c5c1a2a770d3d35a2781ab1cff0ab64ddbf0b --- /dev/null +++ "b/19 \351\231\210\345\246\203/20231214\344\275\234\344\270\232.md" @@ -0,0 +1,57 @@ +# 作业笔记 + +```js +//数组解构 +const [a, b, c] = [1, 2, 3] +console.log(a) //1 +console.log(b) //2 +console.log(c) //3 +//解构嵌套对象 +const obj = { + a:1, + b:2, + c:{ + d:3, + e:4 + } +} +// 方法1: +const {a, b, {d, e}} = obj + +// 方法2: +const {a, b, c} = obj +const {d, e} = c //对c这个对象再进行一步解构 + +//可扩展运算符 +const obj = { a:1, b:2, c:3, d:{e:4} } +const {a, b, ...rest} = obj // 意思是a, b解构出来,obj剩余参数则收拢在一起 +//只不过此时收拢后的结果不是数组,而是收拢在一起成为对象 +console.log(rest) //{c:3, d:{e:4}} +//拷贝 +const arr = [1, 2, 3] +const newArr = [...arr] +newArr.push(100) + +console.log(arr) // [1, 2, 3] +console.log(newArr) // [1, 2, 3, 100] + +/* + jquery事件: + 1.没有on,直接以js事件去掉相应的on即可 + 2.位置:ready()内 + ready(function){ + $("jquery选择器").事件类型(function(){ + 事件体... + }) + } + */ + $(document).ready(function(){ //可缩写为 $(function{}) + // 鼠标单击事件 + $("#myButton").click(function(){ + $("#myText").css("background-color","red"); + }) + })// ready()结束标记 +获得属性 $('').attr('属性名','属性值') + attr({"属性名":"属性值","属性名":"属性值","属性名":"属性值"}):设置多个属性值 + +``` \ No newline at end of file