我有一个下拉列表:
@Html.DropDownList("name", (IEnumerable<SelectListItem>)SlotList[counter], new { id = "slotDDL_" + @item.ResourceID, tid = @item.ResourceID, @class = "slotDDL_ text white" })
和一个复选框:
@Html.CheckBoxFor(modelItem => item.IsSelected, new { @class = "boxcheck_", id = @item.ResourceID })
执行此操作时:
$('.slotDDL_').change(function () {
var resId = $(this).attr("tid");
IsSelected = 'boxcheck_' + resId;
alert($('#' + resId).attr("checked"));
});
我得到以下信息:
alert($(this).attr("tid"))====>505
alert(IsSelected)====> boxcheck_505
alert($('#' + resId).attr("checked"))===>undefined
问题: 如何成功构建我的 Id 字符串?我究竟做错了什么 ?