Okay, I know this should be simple. I have a definition list (<dl>) that contains data definitions and data labels. I have an input in one of the data definitions so a user can define the definition.
I am then trying to get the name of the label for that definition. In the demo the alert should prompt with "cycle_3".
var myErrors = $('.myTest').prev('dt').text();
console.log(myErrors);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<dl>
<dt> cycle_1:</dt>
<dd> test </dd>
<dt> cycle_2: </dt>
<dd> test </dd>
<dt> cycle_3: </dt>
<dd>
<input class="myTest" value="test" />
</dd>
</dl>
1 Answer