易截截图软件、单文件、免安装、纯绿色、仅160KB

css javascript的问题getElementById.type.display

我在网上看到有人这样写:
getElementById("").style.display="none"
还有一个是getElementById("").attributes['class'].value = ''我查了下知道是通过Id得到display的属性和class的属性,我想问下,要得到display必须用.style吗?attributes是得到class,那我可以写成attributes['display']吗?attributes和style有什么区别?
给你看个示例,希望你能看明白
<div id="test" class="testCss" style="display:none;font-size:12px"> </div>
是否看明白了?

要得到display必须用.style吗?

attributes是得到class,那我可以写成attributes['display']吗?
不可以
attributes和style有什么区别?
<td id="tdId" class="c1" style="display:none"> </td>
id,class,style都是属性
attributes是属性集合
通过getElementById("").attributes['style']能得到style属性

attributes是一个集合,得通过下标来访问(准确的说,是个map,通过key来访问)。
getElementById("").style
getElementById("").attributes['style']
我觉得这两种写法是一样的。

另外,目前流行的js框架,已经不需要写如此冗长的代码了,很方便。你可以试试。

谢谢你们,我茅塞顿开啊,尤其是2楼的回答

明白了就结贴散分吧,哈哈

Java code



Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.c


相关问答:

asp中用javascript动态改变Image的src的路径问题

<form id="form1" runat="server">
  <div>
  <script type="text/javascript">
  function oo(a){
  document.getEleme ......

C#写JAVASCRIPT 数组

C#写JAVASCRIPT 数组

      protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
& ......

javaScript 悬停浮动层定位

如何实现当鼠标悬停控件上时,出现该控件的尾部显示对应的层,鼠标移动到该层上进行相应的操作,当鼠标移除时(不在控件上也不在层上)层隐藏,

http://topic.csdn.net/u/20090830/23/5e5ded07-7216-46c2-9712- ......

如何用javascript执行客户端本地程序?

如题,谢谢
1.用activeX
2.用服务器.传递命令给服务器,服务器来运行

javascript不可以吗

js是客户端执行的,权限有限,可以的话,病毒满天飞啦

是啊,如果可以的话,那 JavaScript 执行一个 format c: ......

[javascript]如何复制信息到剪贴板【不带HTML标记的】

用javascript
如何复制信息到剪贴板【不带HTML标记的】

很常见的一个例子,比如我在论坛发帖子的时候,我在编辑器里编辑好一段文字之后,点提交。
这时候JS自动帮我复制了。
如果万一出错,我还可以 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号