Dojo. byid and dijit. byid

Source: Internet
Author: User
Dojo. byid (string ID)

This function is a synonym for document. All. ID in IE or document. getelementbyid (ID) in standard DOM. So you can say:

Dojo. byid ("breadbox"). style. fontsize = "72pt ";

If document. getelementbyid () works in all modern browsers, why use this? Sadly, bugs persist in Internet Explorer which make getelementbyid () unstable in some common scenarios. Also, dojo. byid () is easier to type.

Dijit. byid (string ID)

Because of the almost-identical spelling, this method is commonly mixed up with dojo. byid (string ID ). here's the difference: dijit. byid () returns a dijit widget instance-technically, an instance of dijit. _ widget or one of its subclasses like dijit. toolbar or dijit. treenode.

So here's the way to remember it:

  • If you need a DOM node, use dojo. byid. You need a DOM node anytime you call a standard browser function, change a standard property, etc.
  • If you need a widget, use dijit. byid. From it you can access all of the attributes, methods and extension points listed in Part 2.

Or for you who think in terms of functions (e.g. LISP programmers ?) :

var myDomNode = dojo.byId("foo");var myWidget = dijit.byId("foo");console.debug(myDomNode == myWidget.domNode);  // trueconsole.debug(dijit.byNode(myDomNode) == myWidget); // true

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.