一、Dom
1.改变内容如文字内容 或改变html内容标签属性如href里面的网址
var x=document.getElementById('lin');
x.href="https://www.sogou.com";
x.innerHTML="搜狗";
2.改变css内容
var x=document.getElementById('box');
x.style.backgroundColor="black";
二、js事件
(截图来源于https://ke.qq.com/course/279040)
三、字符串常用内置对象:
document.write(x.length+'<br>');//长度
document.write(x.match("baidu")+'<br>');//有匹配就输出,无就输出null
document.write(x.replace("baidu","sougou")+'<br>');//替换
document.write(x.toLowerCase()+'<br>');//变小写
var y=x.split(".");//分开
document.write(y[1]);
四、时间
var x=new Date();
var a=x.getHours();
var b=x.getMinutes();
var c=x.getSeconds();
document.write(a+":"+b+":"+c)
获取到的date还有很多,这里只是举三个属性
刷新时钟
<body onload="nowt()">
<pid="time"></p>
</body>
function nowt()
{
vary=document.getElementById('time');
varx=new Date();
vara=x.getHours();
varb=x.getMinutes();
varc=x.getSeconds();
if(c>=0&&c<=9)c="0"+c;
y.innerHTML=a+':'+b+':'+c;//不能用document.write不然会一直输出时间,这里是要覆盖
setTimeout(function(){nowt(),1000});//关键函数!刷新
}