style.js
来自「这是《JavaScript学习源代码》一书的源代码」· JavaScript 代码 · 共 26 行
JS
26 行
window.onload=get_styles;
// a function to display the style attributes of a <div>
function get_styles()
{
var obj = window.document.getElementById("lyr");
var str = "ID: " + obj.id + "\n";
str += "Top: " + obj.style.top + "\n";
str += "Left: " + obj.style.left + "\n";
str += "Z-Index: " + obj.style.zIndex + "\n";
str += "Visibility: " + obj.style.visibility + "\n";
str += "Background: " + obj.style.backgroundColor + "\n";
str += "Foreground: " + obj.style.color;
alert(str);
}
function restyle()
{
var obj = window.document.getElementById("lyr");
obj.style.top = "150px";
obj.style.left = "20px";
obj.style.zIndex = "20";
obj.style.backgroundColor = "lime";
obj.style.color = "blue";
get_styles();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?