// 获取子节点
document.getElementById("div").childNodes
// 获取子元素
document.getElementById("div").children[0]
// 第一个子元素
document.getElementById("div").firstChild
// 最后一个
document.getElementById("div").lastChild
// 父元素
document.getElementById("div").parentNode
// 所有的父节点
document.getElementById("div").offsetParent
// 所有的兄弟元素
document.getElementById("div").parentNode.children
// 上一个兄弟元素
document.getElementById("div").previousSibling
// 下一个兄弟元素
document.getElementById("div").nextSibling
const util = require(‘util‘);
util.format(‘%s:%s‘, ‘foo‘);
const crypto = require("crypto")
const getMd5 = (url) => crypto.createHash("md5").update(url).digest("hex");
console.log(getMd5("1234"))
// 时间格式化 new Date().format("yyyy-MM-dd hh:mm:ss")
Date.prototype.format = function(fmt) {
var o = {
"M+" : this.getMonth()+1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth()+3)/3), //季度
"S" : this.getMilliseconds() //毫秒
};
if(/(y+)/.test(fmt)) {
fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
}
for(var k in o) {
if(new RegExp("("+ k +")").test(fmt)){
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
}
}
return fmt;
}
原文:https://www.cnblogs.com/iFanLiwei/p/13647357.html