<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.addClass{
display: inline-block;
margin: 0 auto;
background-color: #0f0;
}
#test {
width: 200px;
height: 200px;
background-color: #0097F7;
padding: 10px;
border: 10px solid #000000;
}
</style>
</head>
<body>
<div id="test">
</div>
<a href="javascript:void(null)">111</a>
<div class="classDiv" id="idDiv" data-id='1' data-name='cq'>你好</div>
<input type="text" name="" id="" value="111" />
<button type="button" id="btn">点击</button>
<script type="text/javascript">
let body = document.body
let html = document.documentElement
console.log(html);
const text = document.querySelector('input')
console.log(text.nodeValue);
let idDiv = document.getElementById('idDiv')
console.log(idDiv.nodeName,idDiv.nodeType,idDiv.nodeValue);
let btn = document.getElementById('btn')
let classDiv = document.getElementsByClassName('classDiv')
let queryDiv = document.querySelector('.classDiv')
idDiv.onclick = function () {
alert(idDiv.innerHTML)
idDiv.className = 'addClass'
idDiv.getAttribute('data-id')
idDiv.setAttribute('data-id','nihao')
console.log(idDiv.dataset);
console.log(window.location);
}
console.log(idDiv);
let li = document.createElement('li')
idDiv.appendChild(li)
let lili = document.createElement('li')
idDiv.insertBefore(lili,idDiv.firstChild)
idDiv.removeChild(idDiv.children[0])
btn.addEventListener('mouseover',function(e){
console.log("mouseover");
console.log(e.clientX,e.clientY);
console.log(e.pageX,e.pageY);
console.log(e.screenX,e.screenY);
})
btn.addEventListener('keydown',function fn(){
console.log('keydown');
btn.removeEventListener('keydown',fn)
},true)
let regex =/^[0-9a-zA-Z]{4}$/
console.log(regex.test('ab1A'));
let test = document.getElementById('test')
console.log('---------');
console.log(test.offsetWidth);
console.log('---------');
let timer = new Date()
console.log(timer.getTime(),timer.getFullYear(),timer.getMonth()+1,timer.getDate());
console.log(timer.getDate());
console.log(timer.getDay());
function fu () {
console.log(this);
}
fu()
function changeTo(){
console.log(111)
}
btn['onclick']=changeTo
var y = 18,res = ''
if(y%4==0 || y%6!=0){
rs='yes'
}else{
rs='no'
}
console.log(rs);
var fn = function (f) {
alert(typeof f)
var f = 2
function f(){}
console.log(f);
}
fn(1)
var arr = ['苹果','橘子','香蕉']
console.log(arr.slice(0));
console.log(arr);
function superFn() {
var x = 0
return function () {
x++
console.log(x);
}
}
var s1 = superFn()
var s2 = superFn()
s1()
s1()
s1()
s2()
</script>
</body>
</html>
转载请注明原文地址:https://ipadbbs.8miu.com/read-53417.html