Would there be a way to access the parent div from the child elemen" /> Would there be a way to access the parent div from the child elemen" /> Would there be a way to access the parent div from the child elemen"/>

Is there a way to access an elements parent in tritium?

110 views Asked by At

for example, let's say there was this html:

<div>
  <div id="divchild"></div>
</div>

Would there be a way to access the parent div from the child elements namespace such as:

$$('#divchild'){
  # Access parent div here
  $$('< div'){
    # somethere here
  }
}

Is there a way to take the non working example and make it work? thank you.

1

There are 1 answers

0
Cagri On

not with the css selectors.You'll need to use xpath selectors:

$(".//div[div[@id='divchild']]") {
    # something here
}

or

$(".//div[@id='divchild']/parent::div") {
    # something here
}

would select the parent div.