각 행에 숨겨진 필드가있는 테이블이 있습니다. 해당 행의 버튼을 클릭하면 숨겨진 필드 값을 경고해야합니다. 다음 jQuery 코드가 있습니다. 그러나 그것은 효과가 없습니다. 우리가 어떻게 작동하게할까요?테이블 행에 숨겨진 필드 값을 가져 오는 jQuery
CODE : http://jsfiddle.net/Lijo/xWanB/
<script>
$(document).ready(function() {
//"Show ID" for Associate Button Click
$('.resultGridTable tr > td > .actionButtonNational').click(function() {
//"this" means show ID button
//Traversing to get the parent row and then the required columns in the row
var associateID = $(this).parents('tr:first > .wrapperDivHidden input[type=hidden]').val();
alert(associateID);
return false;
});
});
</script>
HTML
당신의 선택은tr:first > .wrapperDivHidden ...
로 시작하지만
.wrapperDivHidden
지금과 같이 당신의 선택을 변경
tr
의 즉각적인 자식이 아닌
<td>
XXXXX
<input type="submit" name="ctl00$detailContentPlaceholder$grdSubscribedAssociates$ctl04$btnNational"
value="Show ID" id="detailContentPlaceholder_grdSubscribedAssociates_btnNational_2"
class="actionButtonNational" style="color: White; background-color: #A7A7A6;
font-weight: bold; width: 60px" />
<div id="wrapperDivHidden" class="wrapperDivHidden">
<input type="hidden" name="ctl00$detailContentPlaceholder$grdSubscribedAssociates$ctl04$hdnAssociateID"
id="detailContentPlaceholder_grdSubscribedAssociates_hdnAssociateID_2"value="789345680" />
</div>
</td>
감사합니다. 좋은 설명도 .. – Lijo