javascript - pick specific checkbox value -
i have checkboxs same name each has unique value. want on click on specific checkbox unique value of cpecific clicked checkbox.
@foreach (var itert in model.collec) { @html.checkbox("chkresend", new { @value = html.encode(itert.eventnumber), @class = "myclass" }) };
the jquery is:
$(document).ready(function () { $(".myclass").click(function () { alert($(".myclass").attr("value")); }); });
all time value of first checkbox...
use this keyword
$(document).ready(function () { $(".myclass").click(function () { alert(this.value); //this refers current element clicked // or alert($(this).attr("value")); // or alert($(this).val()); }); });
Comments
Post a Comment