So I have an HTML snippet like
<form action="/AssetBundle/DownloadFile" data-ajax="true" data-ajax-method="POST" data-ajax-mode="replace" data-ajax-update="#masterLinkHolder" id="form0" method="post"></form>
<table>
<tr>
<td>someimage.png</td>
<td><img src="imageicon.png"></td>
<td><button type="button">Click to Download</button></td>
</tr>
<tr>
<td>somedocument.docx</td>
<td><img src="docicon.png"></td>
<td><button type="button">Click to Download</button></td>
</tr>
</table>
<input type="hidden" id="file2Download" />
</form>
and when you click buttonI want to set valuefor the input id file2Downloadas a file name (for example someimage.png, somedocument.docx) from the same tras a button, and then submit the form. Therefore i need help filling out
<script type="text/javascript">
$('button').click(function () {
$('#file2Download').val(
);
$('#id0').submit();
});
</script>
properly. I know that I look at a tree like
tr
/ | \
td td td
| \
img button
and try to switch from buttonto grandparent tr, and then to the first descendant of this tr.
source
share