类与继承
\'use strict\'
class student{
constructor(name){
this.name = name;
}
hello(){
alert(\'hello\');
}
}
class stu2 extends student{
constructor(name,grade){
super(name);
this.grade = grade;
}
xx(){
alert(\'hello\');
}
}
var x1 = new student(\'xiaoli\');
var x2 = new stu2(\'xiaoming\',100);
Date() Map() Set()
var time = new Date; // 获取当前时间
time.getDay(); // 礼拜几 0~6
var tms = time.getTime(); // 时间戳,毫秒
var time2 = new Date(tms);
var map = new Map( [ [\'1\',\'one\'], [\'2\',\'two\'] ] );
var set = new Set( [\'1\', \'2\', \'1\', \'3\'] );
for(let a of map){
console.log(a) // [\'1\', \'one\'] [\'2\', \'two\']
}
BOM DOM
//bom 浏览器对象模型
window.innerHeight .alert(1)
location.href .host
screen.width
document.title .cookie
document.title = \'newTitle\' // 可以直接修改
//dom 文件对象模型
// 删除father下的第一个节点
var father = getElementById(\'fatherid\');
father.removeChild(father.children[0])
//插入节点
var id = document.getElementById(\'idname\'); //
var newp = document.createElement(\'p\'); // 创建标签p
newp.id = \'idp\';
newp.style.color = \'red\'; // 设置样式
newp.innerText = \'ppp\'; // 文本
id.appendChild(newp);
var cssstyle = document.createElement(\'style\'); // 创建标签style
cssstyle.setAttribute(\'type\',\'text/css\'); // 属性
cssstyle.innerHTML = \'div{ background: red}\';
id.appendChild(cssstyle);
//jQuery(需下载) 公式:$(\'selector\').action()
//jQuery API
$(\'#id .class\').html(\'<br>\') / .css({\'color\',\'red\'}); .hide() .width() 等
//鼠标事件
<body>
mouse: <span id = \"mousespan\"></span>
<div id = \"mousediv\" style = \"border:1px solid red;height: 1000px;\">在这里移动</div>
</body>
<script>
$(function(){
$(\'#mousediv\').mousemove(function (e) {
$(\'#mousespan\').text(\'x: \'+e.pageX+\'y: \'+e.pageY);
})
});
</script>
来源:https://blog.csdn.net/W2001r/article/details/123309450
本站部分图文来源于网络,如有侵权请联系删除。