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

来源:互联网 发布:怎么关注新的淘宝达人 编辑:程序博客网 时间:2024/05/16 17:28
<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>

0 0
原创粉丝点击