0

I'm using the following to get an array of values from a set of checkboxes that have been checked by the end-user:

var array = jQuery('input:checkbox[name=items]:checked').map(function() {
    return this.value;
}).get();

Instead of an array of values, I'd like to get an array of classnames.

My checkboxes:

<input type="checkbox" name="items" value="vOne" class="cOne">
<input type="checkbox" name="items" value="vTwo" class="cTwo">
<input type="checkbox" name="items" value="vThree" class="cThree">

I've tried the following which doesn't work:

var array = jQuery('input:checkbox[name=items]:checked').map(function() {
    return this.class;
}).get();
1
  • Check the console, answer is there. Commented Jun 16, 2014 at 17:33

1 Answer 1

2

Instead of this.class, you should use:

this.className
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.