PDA

View Full Version : DomQuery question. Is it possible?



mcohnen
7 Sep 2007, 2:23 AM
Hi,

first of all, this is my first post in these forums, so i want to say hello to everybody here, and apologize for my poor english :( . I am new to DomQuery and Extjs, so if my quetion is to obvious, sorry...

Suppose the following xhtml document:


<a>
<b>
<c>
<d>
</a>
<a>
<b>
<c>
<d>
</a>
<a>
<b>
<c>
<d>
</a>


I have a function for every time a user clicks on <c>. But i want to have access to his <d> sibling in the javascript code function. What i do right now, is looking for my parentNode (<a>) and then i did a function that looks for <a> childrens and return those who have a specified class.

Is there a better way to do that?

Thank you in advance and i hope the explanation is clear enough.

Just to summarize:
User clicks on a <c> element. A javascript event is triggered and in that function i want to have access to the <d> sibling of the previously pressed <c> element.

THANKS!

evant
7 Sep 2007, 2:40 AM
Is c always directly followed by d?

If so:



c.on('click', function(e)
{
var el = Ext.fly(e.getTarget()).getNextSibling();
}
);

Animal
7 Sep 2007, 2:44 AM
Can't you just use the standard DOM element's nextSibling property?

evant
7 Sep 2007, 2:45 AM
You know I thought that just after I posted, but I couldn't be bothered to change it:



c.on('click', function(e)
{
var el = e.getTarget().nextSibling;
}
);


There ;)