<br> function openLogin(obj, attr){<br><br> if(obj.currentStyle) <br> { <br> window.alert(obj.currentStyle[attr]);<br> return obj.currentStyle[attr]; <br> } <br> else <br> { <br> return getComputedStyle(obj,false)[attr]; <br> } </p> <pre><code> } function closeLogin(){ } window.onload=function() { var oDiv=document.getElementById("w"); alert(openLogin(oDiv,"display")) } </script> 百度上找的代码 这样只能获取display的值 请问怎么修改这个值 </code></pre>
1条回答 默认 最新
- Go 旅城通票 2015-04-20 05:54关注
<style>.win{display:none}</style> <div id="w" class="win"> 这是DIV登录框示例<br> </div> <script> function changecss(theClass, element, value) { var cssRules; if (document.all) { cssRules = 'rules'; } else if (document.getElementById) { cssRules = 'cssRules'; } for (var S = 0; S < document.styleSheets.length; S++) { for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) { if (document.styleSheets[S][cssRules][R].selectorText == theClass) { document.styleSheets[S][cssRules][R].style[element] = value; } } } } window.onload = function () { changecss('.win', 'display', 'block'); } </script>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥100 Jenkins自动化部署—悬赏100元
- ¥15 关于#python#的问题:求帮写python代码
- ¥20 MATLAB画图图形出现上下震荡的线条
- ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
- ¥15 perl MISA分析p3_in脚本出错
- ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
- ¥15 ubuntu虚拟机打包apk错误
- ¥199 rust编程架构设计的方案 有偿
- ¥15 回答4f系统的像差计算
- ¥15 java如何提取出pdf里的文字?