随笔分类 -  Javascript

Is a demon.
摘要:1、获取当前一个月中的第几天 var d = new Date(); var n = d.getDate(); document.write(n) 2、设置当前月的天 var d = new Date() d.setDate(15) document.write(d) 主要通过getDate来获取当 阅读全文
posted @ 2021-12-29 16:51 十三月凉 阅读(757) 评论(0) 推荐(0) 编辑
摘要:1、对象转字符串 const obj = { id: 0, name: '张三', age: 12 } const objToStr = JSON.stringify(obj) console.log('obj:', obj) console.log('objToStr:', objToStr) 2 阅读全文
posted @ 2021-12-29 15:17 十三月凉 阅读(3205) 评论(0) 推荐(0) 编辑
摘要://$(".comment_txt").each(function(){ var len=$('#text').text().length; if(len>75){ var str=""; str=$('#text').text().substr(0,75)+"…<span>全文</span>";/ 阅读全文
posted @ 2021-08-26 12:14 十三月凉 阅读(492) 评论(0) 推荐(0) 编辑
摘要:1、加载不同的css样式 var scrWidth = window.screen.width; //获取当前分辨率的大小if(scrWidth == 1920){ //当分辨率为1920是应该引入的css var headHTML = document.getElementsByTagName(' 阅读全文
posted @ 2021-08-17 11:10 十三月凉 阅读(2071) 评论(0) 推荐(0) 编辑
摘要:1.给链接a加个#的方式来实现跳转(锚点方法) <div id="container"> <a href="#div1">div1</a> <a href="#div2">div2</a> <a href="#div3">div3</a> </div> <div id="div1">div1</di 阅读全文
posted @ 2021-04-16 19:57 十三月凉 阅读(1734) 评论(0) 推荐(0) 编辑
摘要:使用方法: swiper的slideTo方法,swiper.slideTo(index,speed,runCallbacks); index:必填,需要跳到页面的索引 speed:选填,切换速度(毫秒) runCallbacks:选填,boolean,为false时不触发onSlideChange回 阅读全文
posted @ 2021-04-15 16:25 十三月凉 阅读(825) 评论(0) 推荐(0) 编辑
摘要://使用window监听pageShow window.addEventListener('pageshow', function (e) { if(e.persisted || (window.performance && window.performance.navigation.type == 阅读全文
posted @ 2021-03-31 16:42 十三月凉 阅读(161) 评论(0) 推荐(0) 编辑
摘要:用animate属性,当点击锚点后,页面滚动到相应的DIV <div id="container"> <p id="p1">div1</p> <p id="p2">div2</p> <p id="p3">div3</p> </div> <div id="div1">div1</div> <div i 阅读全文
posted @ 2021-03-11 19:36 十三月凉 阅读(205) 评论(0) 推荐(0) 编辑
摘要:使用 window.scrollIntoViewIfNeeded window.addEventListener('resize',function(){ if(document.activeElement.tagName "INPUT" || document.activeElement.tagN 阅读全文
posted @ 2021-02-01 19:11 十三月凉 阅读(155) 评论(0) 推荐(0) 编辑
摘要:垂直方向滑动,高度自适应;加载高度获取不正确,导致显示异常。 var ListSwiper = new Swiper('#listText',{ autoHeight:true, observer:true, observeParents:true, direction:'vertical', au 阅读全文
posted @ 2020-12-14 19:41 十三月凉 阅读(2231) 评论(0) 推荐(0) 编辑
摘要:方法一: var endTime = new Date('2018/08/10 11:59:59') alert(endTime.getTime()) 方法二: varendTime = new Date("Jan 1, 1970 00:00:00") console.log(endTime.get 阅读全文
posted @ 2020-12-09 12:36 十三月凉 阅读(689) 评论(0) 推荐(0) 编辑
摘要:$(document).click(function(e){ var box = $('.box'); //目标区域 if(!box.is(e.target) && box.has(e.target).length 0){//Mark console.log(其他区域); // 功能代码 } }); 阅读全文
posted @ 2020-09-29 16:11 十三月凉 阅读(16662) 评论(0) 推荐(1) 编辑
摘要:var time = Date.parse( new Date() ).toString();//获取到毫秒的时间戳,精确到毫秒 time = time.substr(0,10);//精确到秒 阅读全文
posted @ 2020-09-22 17:51 十三月凉 阅读(14228) 评论(0) 推荐(0) 编辑
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script> </ 阅读全文
posted @ 2020-09-16 18:21 十三月凉 阅读(1437) 评论(0) 推荐(0) 编辑
摘要:<select name="searchfield" id="searchfield" onChange="getfield();"> <option value="time" selected>时间</option> <option value="student">学员</option> <opt 阅读全文
posted @ 2020-08-26 11:47 十三月凉 阅读(398) 评论(0) 推荐(0) 编辑
摘要:$('#curclose').index(); 阅读全文
posted @ 2020-08-04 15:43 十三月凉 阅读(1402) 评论(0) 推荐(0) 编辑
摘要:第一种:事件点击触发两次 $(".button").click(function(e){ e.stopPropagation(); //表示阻止向父元素冒泡;阻止默认行为,可以用 event.isDefaultPrevented() 来确定preventDefault是否被调用过了 e.preven 阅读全文
posted @ 2020-07-21 19:56 十三月凉 阅读(2635) 评论(0) 推荐(0) 编辑
摘要:ios端的只读readonly属性不起作用,这个只读属性在安卓上可以阻止输入,所以键盘不会出现,但是在iphone中不兼容,就在iphone中加一个事件,为input添加聚焦事件,聚焦时触发document或自身失焦,或者是在input上添加聚焦时失焦事件 第一种: $('#birthday').f 阅读全文
posted @ 2020-07-06 11:38 十三月凉 阅读(340) 评论(0) 推荐(0) 编辑
摘要:$(选择的元素).click()点击时触发函数,但只是针对页面本身已存在的元素; $(document).on('click','选择的元素',function(){})用法与$(选择的元素).click()一样,但是它最大的区别就是,动态创建的元素能够执行回调函数,而$(选择的元素).click( 阅读全文
posted @ 2020-06-18 18:42 十三月凉 阅读(1780) 评论(0) 推荐(0) 编辑
摘要:1.通过单一字符将字符串切割成多字符 var data= "烈日当头已数月有余,天气高温,汗流浃背,不知所言。"; var str = data.split(','); 结果: str[0] //烈日当头已数月有余 str[1] //天气高温 str[2] //汗流浃背 str[3] //不知所言v 阅读全文
posted @ 2020-05-30 17:27 十三月凉 阅读(21479) 评论(2) 推荐(1) 编辑

/* 看板娘 */
点击右上角即可分享
微信分享提示