this question relates to a another question that I asked previously.
I have a bunch of textbox pairs on my page, each of which have an image associated with them. When clicked, this image should hide itself, and also make the pair of textboxes read-only.
The first part works, it does hide itself. But the second part does not work.
I can't figure out how to 'find' the pair of textboxes that is closest to the image that is being clicked.
Here is my jQuery:
$("body").on('click', '.pageLinks img.save', function () {
$(this).hide();
$(this).prevAll('input').each(function () {
$(this).attr('readonly', 'readonly');
});
Here is my HTML:
<div class="pageLinks">
<div>
<div>
<input type="text" class="firstName">
<input type="text" class="lastName">
</div>
<div>
<img src='/saveLink.png' class='save' />
</div>
</div>
<div>
<div>
<input type="text" class="firstName">
<input type="text" class="lastName">
</div>
<div>
<img src='/saveLink.png' class='save' />
</div>
</div>
<div>
<div>
<input type="text" class="firstName">
<input type="text" class="lastName">
</div>
<div>
<img src='/saveLink.png' class='save' />
</div>
</div>