Trying to get the id from a checkbox that has been clicked
Hi, i can successfully bind click events to dynamically added checkboxes, but
stuck on how to actually get the checkbox's id attribute out.
thanks in advance...
(using mvc 3 with razor)
<script language="javascript" type="text/javascript"> $(document).ready(function () { $('.clickers').bind('click', function (item) { alert($(item).attr('id')); }); }); </script>
@using (Html.BeginForm()) { <div data-role="fieldcontain"> <fieldset data-role="controlgroup" class="clickers"> @foreach (var item in Model.Results) { <label for='@item.TID' >@item.FOO_NAME</label> if (item.Present == true) { <input type="checkbox" name="@item.TID" id="@item.TID" value="true" checked="checked" /> } else { <input type="checkbox" name="@item.TID" id="@item.TID" value="true" /> } } </fieldset> </div>