JS
山海之屿
这个作者很懒,什么都没留下…
展开
-
原生JS 读取图片文件,并显示预览
<div class="form-group"> <label for="exampleInputFile">文章封面</label> <input name="cover" type="file" id="file"> <div class="thumbnail-waper"> <img class="img-thumbnail" src="" id="preview"> </div></d原创 2020-06-02 09:36:12 · 3589 阅读 · 0 评论 -
原生JS map方法 和 jQuery map方法
var arr = [1,2,3,4,5];var obj = {0:1, 1:3, 2:5, 3:7, 4:9};原生js的map第一个参数:当前遍历的元素第二个参数:当前遍历的索引第三个参数:当前遍历的数组不能遍历伪数组arr.map(function (value, index, array) { console.log(index, value, array)});jQuery的map:第一个参数:当前遍历的数组第二个参数:每遍历一个元素之后执行的回调函数回调函数原创 2020-05-26 11:47:56 · 167 阅读 · 0 评论 -
原生JS forEach方法 和 jQuery each方法
第一个参数:当前遍历到的索引第二个参数:遍历到的元素原生js的forEach方法只能遍历数组,不能遍历伪数组var arr = [1,2,3,4,5];var obj = {0:1, 1:3, 2:5, 3:7, 4:9};arr.forEach(function (value, index) { console.log(index, value);});obj.forEach(function (value, index) { console.log(index, val原创 2020-05-26 11:34:37 · 202 阅读 · 0 评论