我的布局类似于:
<div id="..."><img src="..."></div>
Run Code Online (Sandbox Code Playgroud)
并希望使用jQuery选择器来选择点击img内的子项div.
为了得到div,我有这个选择器:
$(this)
Run Code Online (Sandbox Code Playgroud)
如何让孩子img使用选择器?
我有一个表格,每行都有一个隐藏字段.当单击该行中的按钮时,我需要提醒隐藏字段的值.我有以下jQuery代码.但它不起作用.我们如何让它发挥作用?
代码: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>
Run Code Online (Sandbox Code Playgroud)
HTML
<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" …Run Code Online (Sandbox Code Playgroud)