当前位置: 代码迷 >> Web前端 >> Learning Dojo - 4. DOM APIs
  详细解决方案

Learning Dojo - 4. DOM APIs

热度:885   发布时间:2012-11-22 00:16:41.0
Learning Dojo -- 4. DOM APIs
1.Select Node API
  a.dojo.byId()
  b.dojo.query("div.question p")
      i.The parameter here should apply to CSS3 Selector
     ii.This function always returns a NodeList, even if there is only one node selected


2.Attributes Operation
   dojo.attr(), dojo.hasAttr(), dojo.removeAttr() ...


3.CSS Operation
  dojo.style(), dojo.hasClass(), ....

4.Insert/Remove Nodes
   dojo.place(newNode, parentNode, "last");...


Tips
  1.You may find dojo.toggleClass very usefule

   if (error) {
  dojo.addClass(someNode, "displayAsError");
} else {
  dojo.removeClass(someNode, "displayAsError");
}

   //becomes...

  dojo.toggleClass(someNode, "displayAsError", error);