fjanon
29 Jul 2007, 1:01 AM
DomQuery & CSS selector question:
How do I select the next node (sibling) (only the first one) with a specific class name of a node without specifying the tag name of the node I am looking for?
I tried:
first = Ext.get("firstheader");
// I want the id="firstcontent" node now
content = Ext.DomQuery.selectNode('*:next(.content)',first.dom);
without success. I also tried different variations of Dom.Query, Element.select, Element.query with the "next()" pseudo-selector but I always get either an empty array or composite.
Example:
I am looking for the first element with the "content" class starting from a node with the class "header". Basically the user clicks on the "header" and I need to do something with the "content".
My HTML structure:
<div id="Top" class="top">
<div id="firstheader" class="header">
First Header
</div>
<div id="firstcontent" class="content">
First content
</div>
<h2 id="secondheader" class="header">
Second Header
</h2>
<div id="secondcontent" class="content">
Second content
</div>
</div> <!-- id="Top" -->
I know that I can use the Element.getNextSibling() method, but I want a DOMQuery solution to be able to change the structure easily if need be.
I'll also post a request for a documentation addition in 1.1 for the definition of a "sample selector" in Dom.Query.
Thanks
Fred
How do I select the next node (sibling) (only the first one) with a specific class name of a node without specifying the tag name of the node I am looking for?
I tried:
first = Ext.get("firstheader");
// I want the id="firstcontent" node now
content = Ext.DomQuery.selectNode('*:next(.content)',first.dom);
without success. I also tried different variations of Dom.Query, Element.select, Element.query with the "next()" pseudo-selector but I always get either an empty array or composite.
Example:
I am looking for the first element with the "content" class starting from a node with the class "header". Basically the user clicks on the "header" and I need to do something with the "content".
My HTML structure:
<div id="Top" class="top">
<div id="firstheader" class="header">
First Header
</div>
<div id="firstcontent" class="content">
First content
</div>
<h2 id="secondheader" class="header">
Second Header
</h2>
<div id="secondcontent" class="content">
Second content
</div>
</div> <!-- id="Top" -->
I know that I can use the Element.getNextSibling() method, but I want a DOMQuery solution to be able to change the structure easily if need be.
I'll also post a request for a documentation addition in 1.1 for the definition of a "sample selector" in Dom.Query.
Thanks
Fred