I’m having trouble selecting the right element with my jQuery code. This is what the DOM basically looks like:
<div class='bad_link'>
<p><a href='...'>...</a></p>
<p><a href='...'>...</a></p>
<input type='text' size='100' name='....' />
<input class='check_button' type='button' name='check_link' value='Check' />
</div>
I’m trying to grab the value of the input field that is right above the “Check” button, but I’m having trouble doing that.
This is my jQuery code right now:
$(document).ready(function() {
$(".check_button").on('click', function() {
window.alert($(this).siblings().find('input').text());
});
});
How can I grab that value?? Thanks!
.prev()will select the previous element of checkbox.$(this).prev().val();is also an option