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

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

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -