在Jquery中构建复选框的Id

在Jquery中构建复选框的Id,jquery,Jquery,我有一个下拉列表: @Html.DropDownList("name", (IEnumerable<SelectListItem>)SlotList[counter], new { id = "slotDDL_" + @item.ResourceID, tid = @item.ResourceID, @class = "slotDDL_ text white" }) 执行此操作时: $('.slotDDL_').change(function () {

我有一个下拉列表:

 @Html.DropDownList("name", (IEnumerable<SelectListItem>)SlotList[counter], new { id = "slotDDL_" + @item.ResourceID, tid = @item.ResourceID, @class = "slotDDL_ text white" })
执行此操作时:

 $('.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的字符串?我做错了什么

用“#”代替“.”

$('#slotDDL_')
试一试


你错过了
id
属性

@class=“slotDDL\uuutext-white”我需要按类访问它。再一次……我可以访问该函数。我收到警报。我在构造id的名称时遇到问题。你检查了最终的HTML源吗?复选框id 505吗?实际上不止这些:“id=”boxcheck_“+@item.ResourceID”。很好。谢谢
$('#slotDDL_')
@Html.CheckBoxFor(modelItem => item.IsSelected, new { @class = "boxcheck_", id = "@item.ResourceID" })