本文介绍了使用Extj浏览DOM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上选择了我想要的元素,我遇到了一些麻烦。结构如下:

I am having some trouble selecting the element I want on my page. The structure looks like:

<div id="Notepanel-1003_header" class="x-panel-header" style="right: auto; left: 0px; top: 0px; width: 737px;">
<div id="Notepanel-1003-body" class="x-panel-body" style="padding: 10px; width: 737px; height: 423px; left: 0px; top: 44px;" role="presentation" data-ref="body">

我可以得到它来选择 Notepanel-1003_header with

I can get it to select the Notepanel-1003_header with

Ext.ComponentQuery.query('Notepanel')[0] .down()< div id =Notepanel-1003_headerclass =x-panel-headerstyle =right:auto; left:0px; top:0px; width:737px;> code>

Ext.ComponentQuery.query('Notepanel')[0].down() which gives me <div id="Notepanel-1003_header" class="x-panel-header" style="right: auto; left: 0px; top: 0px; width: 737px;">

但是我该如何从这里选择 Notepanel-1003-body ?这两个在同一个级别,我试图添加.next()在最后,但它没有工作。任何建议?

But how do i go from here and select Notepanel-1003-body ? These two are on the same level, i tried to add .next() at the end, but it didnt work. Any suggestions?

推荐答案

首先值得分开组件的概念(,)和(DOM)元素(,)。

First is worth to separate the concept of Components (Ext.Component, Ext.ComponentQuery) and (DOM) Elements (Ext.dom.Element, Ext.dom.Query).

导航通过DOM与Extjs您可以使用

To navigate through DOM with Extjs you can use


  1. Ext.query(什么是别名为,其支持元素选择器,属性选择器,伪类,甚至CSS值选择器,XML命名空间,你可以这样做:

  1. Ext.query (what is alias for Ext.dom.Query.select(), its support element selectors, attribute selectors, pseudo classes and even CSS value selectors, XML namespaces. You can do something like this:

Ext.dom.Query.select('div#Notepanel-1003-body')

它将返回HTML DOM元素

It will return HTML DOM element

Ext.get(什么是),使用节点的ID,DOM节点或现有元素作为其参数。你可以这样做:

Ext.get (what is alias for Ext.dom.Element.get()) using the id of the node, a DOM Node or an existing Element as its argument. You can do something like this:

Ext.get('Notepanel-1003-body')

它将返回

值得注意的是,包含许多导航思想DOM的方法,适用于例如:

Worth noting is that the Ext.dom.Element contains many methods to navigate thought DOM, for example:




  • a href =http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.dom.Element-method-next =nofollow noreferrer> next()

Ext.get('Notepanel-1003_header').next('div')


此外,您还可以查看。

这篇关于使用Extj浏览DOM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 00:00