I have hidden Divs with ".display-link" classes that are two levels up from an input box. When an input (checkbox) is clicked, it should display the hidden link in the parent's previous sibling's wrapper.
Or another way to say it is, when an input checkbox is clicked it should find the previous div with the class .display-link and show() that.
I am having trouble traversing the elements to reach this div with this class. It should only display the one, previous div.
<!DOCTYPE HTML>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$(".display-link").hide();//hide all links
$('input').click (function ()
{
$(this).closest(".display-link").show();//doesn't work
$(this).closest("div.display-link").show();//doesn't work
myInput = $(this);
$(myInput).closest(".display-link").show();//doesn't work
$(myInput).parents(".display-link").show();//doesn't work
$(myInput).prevUntil(".display-link").show();//doesn't work
});
});
</script>
</head>
<body>
<div class="accordion-button">First Heading
<div class="display-link">LINK</div>
</div>
<div class="collapsible">
<div class="input-row">
<input id="checkbox01" name="checkbox01" type="checkbox" value="value01" />
<label for="checkbox01" >Name 1</label>
</div>
<div class="input-row">
<input id="checkbox02" name="checkbox02" type="checkbox" value="value02" />
<label for="checkbox02" >Name 2</label>
</div>
</div>
<div class="accordion-button">Second Heading
<div class="display-link">LINK</div>
</div>
<div class="collapsible">
<div class="input-row">
<input id="checkbox03" name="checkbox03" type="checkbox" value="value03" />
<label for="checkbox03" >Name 3</label>
</div>
</div>
</body>
</html>
I need to go out of the collapsible div and into the accordion-button div down to the display-link div.