2

I have a list of dynamically populated check boxes with values. This code works but with some unnecessary stuffs like text,free text,free text,etc with the value of my checked checkbox

JS:

$('#save').on('click', function () { var val = $(':checked').map(function () { return this.value; }).get() alert(val); }); 
5
  • share your html also... and try $('input:checkbox:checked') Commented Aug 30, 2013 at 8:56
  • all the values of the checked checkbox appears but with some unnecessary text. HELP ME out!! Commented Aug 30, 2013 at 8:56
  • all the values of the checked checkbox appears but with some unnecessary text. HELP ME out!! Commented Aug 30, 2013 at 8:56
  • Refer this stackoverflow.com/questions/5450104/… Commented Aug 30, 2013 at 8:58
  • Check what's the checkbox value using WebDeveloper or something similar. Commented Aug 30, 2013 at 8:58

1 Answer 1

1

Limit your selector to only checbox elements

//or you can use $(':checkbox:checked') var val = $('input[type="checkbox"]:checked').map(function () { return this.value; }).get() 

Demo: Fiddle

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.