<
body
>
<
input
type
=
button
value
=
"切换背景色"
onclick
=
"ChangeBackColor();"
/>
<
script
>
var flag=false;
function ChangeBackColor(){
if(flag){
document.body.style.backgroundColor="red";
}else{
document.body.style.backgroundColor="yellow";
}
flag=!flag;
}
</
script
>
</
body
>