/*
js流程控制語句:
1)if...else
2)for循環控制語句
3)switch循環語句
*/
function centent_if() {
var x = 12;
if(x>18){
alert("恭喜你,你成年了");
}else{
alert("很抱歉,你還是個胖娃娃...");
}
}
function content_for(){
for(var i=0;i<=12;i++){
alert(i);
}
}
function table_test() {
document.getElementById("table_test").innerHTML = "" +
"<table>" +
" <tr style='background-color: aqua'>" +
" <td> </td> " +
" <td> </td> " +
" <td> </td> " +
" </tr>" +
" <tr style='background-color: antiquewhite'>" +
" <td> </td> " +
" <td> </td> " +
" <td> </td> " +
" </tr>" +
" <tr style='background-color: blueviolet'>" +
" <td> </td> " +
" <td> </td> " +
" <td> </td> " +
" </tr>" +
"</table>";
}
function content_switch() {
var x = 12;
switch (x) {
case 10:
alert("x="+x);
break;
case 12:
alert('x:'+x);
break;
default:
alert('None');
break;
}
}
function content_while() {
while (true){
window.console.log("aaaaa");
window.console.log("aaaaa");
window.console.log("aaaaa");
break;
}
}
鑑於js比較容易入門,就不再作演示了