- Ext JS 3.0 Cookbook
- Jorge Ramon
- 189字
- 2021-04-01 13:43:43
Retrieving DOM nodes and elements
Web development involves hefty doses of DOM manipulation. This recipe shows how you can use Ext JS to get a handle on any DOM element.
How to do it...
Using a div element as an example, you can get a handle to the div in the following way:
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css"
href="../ext/css/ext-all.css"/>
<script type="text/javascript" src="../ext/ext-base.js"></script>
<script type="text/javascript"
src="../ext/ext-all-debug.js"></script>
<script type="text/javascript"> Ext.BLANK_IMAGE_URL = '../ext/images/default/s.gif';
Ext.onReady(function() {
var firstDiv = Ext.get("div-1");
Ext.Msg.alert('Using Ext.get(el)', firstDiv.id);
});
</script>
</head>
<body>
<div id="div-1">This is the first div</div>
</body>
</html>
How it works...
The previous code uses Ext.get(element)
, a shorthand for Ext.Element.get(element)
, to acquire a reference to a div element in the document. You can use this function to retrieve references that encapsulate DOM elements.
There's more...
The Ext.get(element)
function uses simple caching to consistently return the same object. Note that Ext.get(element)
does not retrieve Ext JS components. This is can be accomplished using Ext.getCmp()
, explained in the next recipe.
See also...
- The next recipe, Acquiring references to Ext JS components, explains how to obtain a reference to a previously created component.
- The Running high performance DOM queries recipe, which is covered later in this chapter, teaches you how to run queries against the DOM using Ext JS.
推薦閱讀
- Word論文排版之道
- Microsoft Visual C++ Windows Applications by Example
- ERP沙盤模擬簡明教程
- 中文版Photoshop CS6全能一本通·全彩版
- 印象筆記留給你的空間2.0:個(gè)人知識(shí)管理實(shí)踐指南
- 輕松玩轉(zhuǎn)3D One AI
- Building Websites with Joomla! 1.5
- AI繪畫與攝影實(shí)戰(zhàn)108招:ChatGPT+Midjourney+文心一格
- Origin 2022科學(xué)繪圖與數(shù)據(jù)分析
- 科技繪圖/科研論文圖/論文配圖設(shè)計(jì)與創(chuàng)作自學(xué)手冊:科研動(dòng)畫篇
- Photoshop后期強(qiáng):多重曝光專業(yè)技法寶典
- AutoCAD 2019中文版實(shí)戰(zhàn)從入門到精通
- 零基礎(chǔ)學(xué)Photoshop CS6(全視頻教學(xué)版)
- FLUENT 15.0流場分析實(shí)戰(zhàn)指南
- 工作型PPT該這樣做