js 基础
来源:互联网 发布:淘宝秒杀系统繁忙 编辑:程序博客网 时间:2024/06/07 11:48
<!DOCTYPE html>
<html lang="en">
<head>
<!--
只能用于IE浏览器
Object.currentStyle.():获取非行内样式//只能用于IE可以获取默认样式和基本样式 不能获取复合样式
用于火狐,Chrome等浏览器
getComputedStyle(object,false).()
Object.style.()只能获取行内样式
-->
<style type="text/css">
#div{width: 100px;height: 100px;background-color: #123456;}
</style>
<script type="text/javascript">
window.onload=function(){
oDiv=document.getElementById('div');
oBtn=document.getElementsByTagName('input')[0];
oBtn.onclick=css(oDiv,'width','200px');
function getStyle(oDiv,attr){
if(oDiv.currentStyle)
{alert(oDive.currentStyle[attr]) ;}
// {return oDive.currentStyle[attr];}
else
// {return getComputedStyle(oDive,false)[attr];}
{alert(getComputedStyle(oDiv,false)[attr]);}
}
function css(oDiv,attr,value){
if(arguments.length==2)
{getStyle(oDiv,attr);}
else if(arguments.length==3)
{oDiv.style[attr]=value;}
}
}
</script>
<meta charset="UTF-8">
<title>获取样式</title>
</head>
<body>
<input type="button" value="Change">
<div id="div"></div>
</body>
</html>
<html lang="en">
<head>
<!--
只能用于IE浏览器
Object.currentStyle.():获取非行内样式//只能用于IE可以获取默认样式和基本样式 不能获取复合样式
用于火狐,Chrome等浏览器
getComputedStyle(object,false).()
Object.style.()只能获取行内样式
-->
<style type="text/css">
#div{width: 100px;height: 100px;background-color: #123456;}
</style>
<script type="text/javascript">
window.onload=function(){
oDiv=document.getElementById('div');
oBtn=document.getElementsByTagName('input')[0];
oBtn.onclick=css(oDiv,'width','200px');
function getStyle(oDiv,attr){
if(oDiv.currentStyle)
{alert(oDive.currentStyle[attr]) ;}
// {return oDive.currentStyle[attr];}
else
// {return getComputedStyle(oDive,false)[attr];}
{alert(getComputedStyle(oDiv,false)[attr]);}
}
function css(oDiv,attr,value){
if(arguments.length==2)
{getStyle(oDiv,attr);}
else if(arguments.length==3)
{oDiv.style[attr]=value;}
}
}
</script>
<meta charset="UTF-8">
<title>获取样式</title>
</head>
<body>
<input type="button" value="Change">
<div id="div"></div>
</body>
</html>
0 0
- js基础
- js基础
- js基础
- js基础
- JS基础
- js基础
- js基础
- JS基础
- js基础
- js基础
- js基础
- js基础
- JS基础
- js 基础
- js-基础
- js基础
- js基础
- js基础
- Tensor Flow textum 使用过程中 遇到的问题和解决
- iOS开发系列--地图与定位
- CSS之display:inline、block、inline-block
- 为什么现代机房管理离不开秦安(kinan)KVM切换器
- 【转】 Openssl之BIO系列
- js 基础
- H5初学界面跳转
- 使用异步 I/O 大大提高应用程序的性能
- 史上最轻量级的新手引导库
- 这个执行频率是怎么算?
- OPENSSL及SSH生成密钥示例
- 如何把文件模版上传到SAP数据库层
- 用nginx-rrd监控nginx访问数
- iOS UILabel根据字体,自适应宽度