随笔
<style>
#div1{
width: 100px;
height: 100px;
background-color: red;
}
</style>
</head>
<body>
<div id="divid"></div>
<div class="divclass"></div>
<div class="divclass"></div>
<input name="inputname" type="text" />
<input type="button" onclick="btn()" />
<div id="test"></div>
<!--<div id="czsx" style="width: 200px;height: 200px; border: 1px solid black;">
123
</div>-->
<table id="czsx">
<tr>
<td>123</td>
</tr>
</table>
<input id="btn-cz" type="button" value="提交" />
<div id="div1"></div>
<script>
// var count = 0;
// for(var i = 3; i < 1001; i++) {
// var status = 0;
// for(var j=2;j<i;j++){
// if(i%j ==0)
// {
// status = 1;
// break;
// }
// }
// if(status ==0)
// {
// document.write(i + "<br>");
// count++;
// }
// }
// alert(count);
// document.alert("弹窗");
// window.alert("弹窗");
// 1.id选择器
document.getElementById("divid").innerHTML = "啦啦啦啦啦";
// 2.class选择器
var divc = document.getElementsByClassName("divclass");
// alert(typeof(divc));
divc[0].innerHTML = "嘿嘿嘿嘿";
divc[1].innerHTML = "哈哈哈哈";
for(var i = 0 ;i<divc.length;i++)
{
divc[i].innerHTML += "略略略略";
}
// 3.标签选择器
document.getElementsByTagName("div")[0].innerHTML += "耶耶耶耶";
// 4.name选择器
document.getElementsByName("inputname")[0].value = "哒哒哒嗒";
var input = document.getElementsByName("inputname")[0].value;
// alert(input);
function btn(){
var div1 = document.getElementById("divid");
div1.innerHTML += "oooooooo";
}
// document.getElementById("test").innerHTML = "<b>加粗</b>";
document.getElementById("test").innerText = "<b>加粗</b>";
document.getElementById("czsx").setAttribute("bgcolor","red");
document.getElementById("btn-cz").setAttribute("disabled","disabled");
document.getElementById("btn-cz").removeAttribute("disabled");
var btn_cz = document.getElementById("btn-cz").getAttribute("value");
// alert(btn_cz);
var div1 = document.getElementById("div1");
// div1.setAttribute("style","width: 200px;height:200px;background-color: red;");
// div1.style.width = "100px";
// div1.style.height = "100px";
// div1.style.backgroundColor = "red";
alert(div1.style.width);
</script>
</body>