随笔分类 - JavaScript/jQuery
摘要:有一个需求是在已有列表中搜索关键词,然后在列表中展示含有相关关键字的数据项并且对关键字进行高亮显示,所以该需求需要解决的就两个问题: 1.搜索关键词过滤列表数据 2.每个列表高亮关键字 ps: 此问题基于数组对象,其他数据类型也可参考此思路。 关键词搜索:过滤数据很简单,无非就是监听search,对
阅读全文
摘要:isElementInViewport (el, offset = 0) { const box = el.getBoundingClientRect(), top = (box.top >= 0), left = (box.left >= 0), bottom = (box.bottom <= (
阅读全文
摘要:var str = 'aa dd c dddd e';str = str.replace(/\s+/g, ' ');//将字符串里的多个连续空格替换成一个空格
阅读全文
摘要://滚动条在内容更新时自动滚到底部var message = document.getElementById('message');message.scrollTop = message.scrollHeight;
阅读全文
摘要:var m1 = moment('2018-08-14 11:00:00'), m2 = moment('2018-08-14 12:10:00'); console.log(m1)console.log(m2)console.log(m2.diff(m1, 'minute'));minute为分钟
阅读全文
摘要:var str = 'sdfsdfds '; str.replace(/(^\s*)|(\s*$)/g, "");
阅读全文
摘要:第一 JSON文件里面不能有任何注释,不能使用单引号,必须使用双引号; 第二 JSON文件名不能使用特殊字符 - ,比如 test-a.json 否则不会返回任何数据也不会报错。 使用方法: $.getJSON("your file path", function(data){ console.lo
阅读全文
摘要:$(window).height(); //浏览器时下窗口可视区域高度 $(document).height(); //浏览器时下窗口文档的高度 ($(document.body).height();//浏览器时下窗口文档body的高度 $(document.body).outerHeight(true);//浏览器时下窗口文档body的总高度 包括border padding margin $...
阅读全文
摘要:html: js: 实现的思路就是响应键盘事件。下面是搜集到的keyCode:
阅读全文

浙公网安备 33010602011771号