I want to select the following three values from the HTML file either by Jquery or Javascript.
- class “class1” href value
- class “class1” inner text value (PersonA in the example code)
- class “Title” inner text value (Accountant in the example)
How can I select all the data of li node by node as? I am lost 🙁
<ol id="result-set">
<li id="v-0">
<div class="result-data">
..
<h2>
<a class="class1" href="">PersonA</a>
</h2>
<dl class="basic">
<dt>Title</dt>
<dd class="title">Accountant</dd>
....
</dl>
</div>
</li>
<li id="v-1">
...
</li>
.....
To get “PersonA”:
$('#v-0 h2 a').html();To get href of that link:
$('#v-0 h2 a').attr('href');To get “Accountant”:
$('#v-0 dl dd').html();You can modify the id (“v-0”) at the start of the selector to choose a particular “row” of your data set.