您的位置:首页 > Web前端 > JavaScript

js 事件 通过内部style改变背景色(一)

2014-01-21 16:17 330 查看
<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>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: