Tom Gullen
Tom Gullen

Reputation: 61727

Jquery foreach loop

$("#<%=ApprovalSelectPanel.ClientID %> input:checkbox:checked").each(function(){

    alert(this.val);

});

This isn't returned the value attribute on each checkbox, it's returning undefined

Upvotes: 1

Views: 298

Answers (1)

Mutation Person
Mutation Person

Reputation: 30498

In this context, this is the DOM object.

Try this instead:

$("#<%=ApprovalSelectPanel.ClientID %> input:checkbox:checked").each(function(){

    alert($(this).val());

});

Although, this work have worked as well:

    alert(this.value);

Upvotes: 5

Related Questions