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

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -

PHPMotion implementation - URL based videos (Hosted on separate location) -