var d = new Date(); d.setDate(d.getDate() - 2); console.log(d.toString()); // First of month var c = new Date(2017,1,1); // 1 Feb -> 30 Jan c.setDate(c.getDate() - 2); console.log(c.toString()); // First of year var b = new Date(2018,0,1); // 1 Jan -…
这里就不多说了,直接贴上代码: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta http-equiv="Content-Language" content="zh-cn"> <title>时间</title> </head…
题目: 思路: 这题是比较典型的树的遍历问题,思路就是将中序遍历作为位置的判断依据,假设有个节点A和它的父亲Afa,那么如果A和Afa的顺序在中序遍历中是先A后Afa,则A是Afa的左儿子,否则是右儿子. 用for遍历一遍所有的节点,让每一个节点都连接到它的父亲,最后从根节点开始访问即可. 代码: // // main.cpp // Tree // // Created by wasdns on 16/12/19. // Copyright ? 2016年 wasdns. All rights…
function getarray(arr,num){ //复制数组,不能直接在原数组上修改 var temparr=new Array(); //遍历原数组 for(var i in arr){ //将原数组中数据一个个压入新数组中 temparr.push(arr[i]); } var returnarr=new Array(); for(var i=0;i<num;i++){ //判断数组是否还有可以取出的数字,防止下标越界 if(temparr.length>0){ //随机生成数字在…
title= {{= x.replace(/ /g,' ') 通过replace将数据进行处理再展示…
async (默认: true) 默认设置下,所有请求均为异步请求.如果需要发送同步请求,请将此选项设置为 false.注意,同步请求将锁住浏览器,用户其它操作必须等待请求完成才可以执行. var temp; $.ajax({         async: false,         type : "POST",         url : defaultPostData.url,         dataType : 'json',         success : functi…
<html> <head> <script type="text/javascript"> function setFocus() { document.getElementById('password1').focus() } function loseFocus() { document.getElementById('password1').blur() } </script> </head> <body>…
今天在做一个按钮的功能控制,点击之后,要根据判断条件,修改按钮的样式,然后就发现了一个巨好用的方法, <button type="button" id="btn_Add" class="btn btn-primary" onclick="AddAttachMent()">增加</button> <script type="text/javascript"> functio…
/*获取指定日期前或者后指定间隔时间* sdate:指定日期* interval:时间间隔* caret:间隔符*/function getNowFormatDate(sdate,interval,caret) { var patt1 =  /^\d{4}-([0-1]?[0-9])-([0-3]?[0-9])$/;  //判断输入的日期是否符合格式正则表达式 if(!(sdate && typeof(sdate) == "string" &&  pat…