<html>
<head>
<script>
/*function test1(){
//window.alert("ok!");
}
function test2(e){
//window.alert("x = "+e.clientX+" y = "+e.clientY);
}
*/
function test3(){
var date = new Date();
window.alert(date.toLocaleString());
}
function change(eobj){
var mysty = document.getElementById("mystyle");
if(eobj.value == "blue"){
//window.alert("OK");
mysty.style.backgroundColor = "blue";
}else{
mysty.style.backgroundColor = "pink";
}
}
</script>
</head>
<body>
<input type = "button" value="当前时间" onclick = "test3()"/>
<div id = "mystyle" style = "width:400px;height:300px;background-color:pink">
div1
</div>
<input type = "button" value="pink" onclick = "change(this)"/>
<input type = "button" value="blue" onclick = "change(this)"/>
</body>
</html>
js 事件 通过内部style改变背景色(一)
最新推荐文章于 2024-06-15 07:33:35 发布