-
Book Overview & Buying
-
Table Of Contents
Ext JS 3.0 Cookbook
By :
Now you'll see how to run queries against the DOM using Ext JS—a must-have when you need to manipulate or perform actions on multiple, related DOM elements. The examples show how to reference all the div elements in a document, obtain all the elements with a CSS class name msg, and iterate over the options of a select element.
The following code snippets are examples of how to run high-performance queries against the DOM using Ext JS:
Ext.onReady(function() {
// Get all the div elements.
var nodes = Ext.query('div');
Ext.each(nodes, function(item, index, allItems) {
document.write(index + '<br/>');
});
});
msg, use the following code snippet:var msgLinks = Ext.query('.msg');
Ext.each(msgLinks, function(item,index) {
// Do something with the element here.
});
var select = Ext.get('countries-select');
Ext.each(select.options, function(item,index) {
// Do something with the item here.
});
The previous examples use Ext.query(path, [root]), a shorthand of Ext.DomQuery.select(path, [root]), to retrieve an array of DOM nodes that match a given selector.
DomQuery provides high-performance selector/XPath processing by compiling queries into reusable functions. It works on HTML and XML documents, supports most of the CSS3 selector's specification as well as some custom selectors and basic XPath, and allows you to plug new pseudo classes and matchers.
Change the font size
Change margin width
Change background colour