I’m dealing with a webpage that lists facilities in different columns using unordered lists. Each column has a separate <ul> with various facilities represented as list items (<li>).
I need to get the second <ul> and only the fourth and fifth list items from it. When I use document.querySelector(".text-body li"), I only receive items from the first <ul>, but I’m interested in the second one instead.
All of the lists have the same class name .text-body so that’s making it tricky.
<div class="text-block hospital-facility" id="section-facilities">
<h2 class="text-block-title"></h2>
<div class="facility-list">
<h4 class="text-block-list-title">Comfort During Stay</h4>
<div class="text-body add-view-more" data-visible-item="6" data-showmore-text="More Details">
<ul>...</ul>
</div>
</div>
<div class="facility-list">
<h4 class="text-block-list-title">Financial Services</h4>
<div class="text-body">
<ul>
<li>Healthcare insurance coordination</li>
<li>Medical travel insurance</li>
<li>Foreign currency exchange</li>
<li>Local ATM services</li>
<li>Credit card transactions</li>
</ul>
</div>
</div>
</div>
Here, the second <ul> has various payment methods, and I want to retrieve all of them. I know about ul:last-child, but since there are several <ul> elements, I need to figure out how to specifically select the second one.