This is a migrated thread and some comments may be shown as answers.

Obtaining next element after a specific element

1 Answer 45 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 24 Aug 2020, 07:23 PM

Hello,

I'm needing a smidge of help on this one :) 

I am looking to obtain a div after the innertext of a specific h5.  as you can see below.  I have an h5 tag titled peoplefinder then a p tag with "text options" as the inner text.

What I'm wanting to do is select the proper text options inner text based on the h5 that's right before it, as text options is prevalent throughout.

<div data-v-03e70c58="" class="card-body">
    <div data-v-03e70c58="" class="card-icon"><svg data-v-03e70c58="" aria-hidden="true" focusable="false" data-prefix="fal" data-icon="chevron-right" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 512" class="svg-inline--fa fa-chevron-right fa-w-8"><path data-v-03e70c58="" fill="currentColor" d="" class=""></path></svg></div>
    <h5 data-v-03e70c58="" class="card-title">peoplefinder</h5>
    <p data-v-03e70c58="" class="card-text">Text Options</p>
</div>

1 Answer, 1 is accepted

Sort by
0
Plamen Mitrev
Telerik team
answered on 26 Aug 2020, 12:52 PM

Hello David,

In most cases, when you need to to find a specific element in the DOM structure, you can use chained find expression. However, in this case the <h5> and <p> elements are on the same level and you need to navigate the DOM tree in a coded step. In order to do that, you need to find one of the elements in a unique way and navigate from there to its sibling, parent or child element.

I hope I have understood your scenario and that the above suggestion will help you automate it. Please do not hesitate to contact us again, if you have follow up questions or you need further assistance. We can continue our discussion here until we wind the best way approach for this case.

Regards,
Plamen Mitrev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Plamen Mitrev
Telerik team
Share this question
or