学习笔记之DHTML部分


---DHTML Object Model (DOM)---

DOM: DHTML的元素都都可以用 目录树的结构进行访问

访问元素的方法:
 Document.all("myID")
 Document.all(IndexID)
 document.all.MyID 
 MyID

同ID的元素有多个时:
 if (document.all("MyID").length != null)
  alert("The first element that has the identifier MyID: " + document.all("MyID").item(0).tagName);
 或:
 var el = document.all.item("MyID",0);
 if (el != null)
     alert("The first element that has the identifier MyID: " + el.tagName);
 
根据标签类型取同一类型的东东进行操作:
 var doc_tables = document.all.tags("TABLE");
 for (i=0; i<doc_tables.length; i++)
     doc_tables(i).border = 1;

 var coll = document.all.tags("H1");
 for (i=0; i<coll.length; i++)
     coll[i].style.color = "green";

用Attribute 来动态访问 property及增加属性
  用getAttribute, setAttribute, and removeAttribute

     if (MyHeading.getAttribute("align")=="middle")
         MyHeading.setAttribute("align","center");
     if (MyHeading.getAttribute("xyz")!="123")
         MyHeading.setAttribute("xyz","123");

访问一个元素的所有子元素,直接子元素,父元素
 myID.All myID.children  myID.parentElement

参考内容:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtml_reference_entry.asp

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值