Document=网页
Object Model=操作方法
事件绑定
where:特定区域
how:触发事件
what:做一些事情
把背景从白色变成黑色
var b = document.querySelector("body");
b.setAttribute("style","background-color:black;");
var dark = "background-color: black; color: white;";
var day = "background-color: white; color: black;";
var button = document.querySelector(".nav");
var web = document.querySelector("body");
function lightSwitch() {
if (web.style.cssText==dark){
web.style.cssText = day;
alert("Day mode");
}
else{
web.style.cssText = dark;
alert("Night mode");
}
}
button.onclick = lightSwitch
将广告去除
el = document.querySelector("#content_right");
el.setAttribute("style","display:none");
///将display的block变为none