- 博客(6)
- 问答 (1)
- 收藏
- 关注
原创 改变函数内部的this指向
1,call()方法call()方法可以改变函数内部this的指向,常用来做继承<script> function Father(name,age,sex) { this.uname = name; this.age = age; this.sex = sex; } function Son(name,age,sex) { Father.call(this,name,age,sex)
2021-01-27 02:49:03
210
1
原创 数组迭代(遍历)方法
1.forEach()方法<script> let arr = [1,2,2,3,6]; arr.forEach(function(val,index) { console.log(index + ':' + val); })</script>arr.forEach(function(val,index){ })用于遍历数组,参数index为数组索引号,val为对应索引号的数值2.filter()方法<script&g.
2021-01-24 20:00:31
1036
原创 构造函数与原型链
1.构造函数中的成员构造函数有静态成员和实例成员<script> function Star(name,age) { this.uname = name; this.age = age; this.song = function() { } } Star.sex = '男', let ldh = new Star('刘德华','18'); console.log(ldh.age);
2021-01-24 14:23:24
493
5
原创 for-of与for-in的区别
1.for-of与for-in遍历数组的区别for-in语句是一种严格的迭代语句,用于枚举对象中的非符号键属性for-of语句是一种严格的迭代语句,用于枚举可迭代对象的元素<script>console.log('for-in显示内容:');let arr = [1,2,3,4,5,6];for (const key in arr) { console.log(key + ':' + arr[key]);}console.log('----------------
2021-01-19 00:35:03
366
原创 jQuery里面的选择属性和修改属性
在jQuery中,我们可能会给元素添加自有属性,也有可能添加自定义属性,所以在修改时,jQuery给我们提供了相对应的选择方法1.prop()方法prop()方法是处理html元素自带固有属性时使用<a href="www.123.com" target="_self" class="123"></a><script> $(function() { $('.123').prop('href'); console.log($('.123').prop('h
2021-01-13 13:22:50
573
2
原创 JQuery的增加元素,删除元素
JQuery的增加元素,删除元素1. jQuery创建元素方法let div = $('<div>elm</div>');$('<div>elm</div>')可以创建一个div元素,并内容为elm2.添加元素2.1.内部添加append(),prepend()方法<ul> <li>原有的</li></ul><script> $(function(...
2021-01-11 22:06:43
384
1
空空如也
在多个事件绑定时,用for-in遍历会报错,用for循环就不会出错,怎么解决
2021-02-01
TA创建的收藏夹 TA关注的收藏夹
TA关注的人