Get Unique names of Dynamic Check box by class using jQuery
In your MVC View
JS@model IEnumerable<ProjName.Models.ModelClass>
@{
if(Model!=null)
{
int count= Model.Count();
<table >
<tr>
<td >
<div id="divId" class="scrollable">
<table >
@for (int i = 0; i< count; i++ )
{
string cbName = @Model.ElementAt(i).UniqueId.ToString();
<tr>
<td align="left" >
<div style=" font-weight:bold">
@Html.CheckBox(cbName , Model.ElementAt(i).IsChecked, new { @class="cbclass"}) @Model.ElementAt(i).Description
</div>
</td>
</tr>
}
</table>
</div>
</td>
</tr>
</table>
}
}
$("#btnGetChecked").click(function () {
var values = $('input:checkbox:checked.cbclass').map(function () {var cbname = this.name;return cbname;}).get();
});