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);

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.