您的位置:首页 > 编程语言

简单的颜色查看页面代码——基于DOM的实现

2007-05-25 13:04 405 查看
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
<!--
function go(){
var colorValue = document.getElementById("colorInput").getAttribute("value",0);
var displaySpanStyle = document.getElementById("displaySpan").getAttribute("style",0);
displaySpanStyle.setAttribute("backgroundColor",colorValue,0);
}
-->
</script>
</head>
<body>
<input type="text" id="colorInput" />
<button onclick="javascript:go();">确定</button>
<span id="displaySpan" style="width:50pt;height:10pt;background-color:red;"></span>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: