0

私はドロップダウンリストを持っています:

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

および CheckboxFor:

@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 の文字列を正常に作成するにはどうすればよいですか? 私は何を間違っていますか?

4

2 に答える 2

0

「。」の代わりに「#」を入力します。

$('#slotDDL_')
于 2012-09-04T13:42:19.370 に答える