我需要在连续点击任意位置时获取所有值,并从
中获取隐藏变量$("tr.podTableRow td:not(.pdficon)").click(function() {
var tableData = $(this).closest('tr').children('td').map(function() {
return $(this).text();
}).get();
var podActualDeliveryDate = $.trim(tableData[0]);
var podOrderNo = $.trim(tableData[1]);
var podDeliveryNo = $.trim(tableData[2]);
var podfileName = $("#fileNameDelete", this).val();
var podFilePath = $(this).find("td.pdficon a").attr("href");)};
此处我无法获得podfileName
&的价值podFilePath
。
<tr class="podTableRow">
<td>
<a href="#tandcLightbox1" class="open-inline-popup-link confirmpopup1"style="display: none;"></a>
${podfiles.actualDeliveryDate}
</td>
<td class="pdficon">
<a href="${podfiles.path}" target="_blank">
<img src="/etc/designs/nextgen/shell/images/pdf.png" style="width: 20px;">
</a>
</td>
<td class="pdficon">
<a href="#delete-pod-lightbox" class="open-inline-popup-link confirmpopupPOD" style="display: none;"></a>
<a href="#" class="icon-alone delete deleteicon">
<span aria-hidden="true" class="icon-close"></span>
<span class="visuallyHidden">Close</span>
<input type="hidden" value="${podfiles.delcoCode}" id="delcoCodeDelete" name="delcoCodeDelete" />
<input type="hidden" value="${podfiles.fileName}" id="fileNameDelete" name="fileNameDelete" />
</a>
</td>
</tr>
答案 0 :(得分:0)
小心你的HTML代码:它无效。 对于你的问题: HTML:
<table>
<tbody>
<tr class="podTableRow">
<td>
<a href="#tandcLightbox1" class="open-inline-popup-link confirmpopup1" style="display: none;"></a>my date1
</td>
<td class="pdficon">
<a href="mypath1" target="_blank">
<img src="/etc/designs/nextgen/shell/images/pdf.png" style="width: 20px;">
</a>
</td>
<td class="pdficon">
<a href="#delete-pod-lightbox" class="open-inline-popup-link confirmpopupPOD" style="display: none;"></a>
<a href="#" class="icon-alone delete deleteicon"> </a>
<span aria-hidden="true" class="icon-close"></span>
<span class="visuallyHidden">Close</span>
<input type="hidden" value="delname1" id="delcoCodeDelete" name="delcoCodeDelete" />
<input type="hidden" value="filename1" id="fileNameDelete" name="fileNameDelete" />
</td>
</tr>
<tr class="podTableRow">
<td>
<a href="#tandcLightbox1" class="open-inline-popup-link confirmpopup1" style="display: none;"></a>mydate2
</td>
<td class="pdficon">
<a href="mypath2" target="_blank">
<img src="/etc/designs/nextgen/shell/images/pdf.png" style="width: 20px;">
</a>
</td>
<td class="pdficon">
<a href="#delete-pod-lightbox" class="open-inline-popup-link confirmpopupPOD" style="display: none;"></a>
<a href="#" class="icon-alone delete deleteicon"> </a>
<span aria-hidden="true" class="icon-close"></span>
<span class="visuallyHidden">Close</span>
<input type="hidden" value="delname2" id="delcoCodeDelete" name="delcoCodeDelete" />
<input type="hidden" value="filname2" id="fileNameDelete" name="fileNameDelete" />
</td>
</tr>
</tbody>
</table>
JS:
$(".podTableRow").click(function() {
alert($(this).children('td:first').text());
alert($(this).children('td:nth-child(2)').children("a").attr('href'));
alert($(this).children('td:nth-child(3)').children('input[name="delcoCodeDelete"]').val());
alert($(this).children('td:nth-child(3)').children('input[name="fileNameDelete"]').val());
});
你可以在这个jsfiddle上测试它:https://jsfiddle.net/HRoux/s0uk8e76/
总而言之,你可以和.children()一起玩任何你想要的东西。