ExtJs syntax for document.getElementById()

The getElementById() method accesses the first element with the specified id. It can be a div tag or any other HTML element with the specified id. After you get reference to the element its easy to get and set values. So how do you achieve the same thing in ExtJs. It's pretty easy in ExtJs as well.

Ext.get - Retrieves Ext.Element objects. get is an alias for Ext.Element.get.
  • Parameters
    • el : String/HTMLElement/Ext.Element
    • The id of the node, a DOM Node or an existing Element.
  • Returns
    • Ext.Element
    • The Element object (or null if no matching element was found)

Examples:
// by id
var el = Ext.get("myDivId");
// by DOM element reference
var el = Ext.get(myDivElement);

Ext.dom - Return the dom node for the passed String (id)
  • Parameters
    • el : String/HTMLElement/Ext.Element
Examples:
// by id
var el = Ext.getDom('myDivId');
// by DOM element reference
var el = Ext.getDom(myDivElement);

No comments:

Post a Comment

NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.