Why do spaces appear in my string?
Posted
by Abs
on Stack Overflow
See other posts from Stack Overflow
or by Abs
Published on 2010-04-26T12:16:21Z
Indexed on
2010/04/26
12:23 UTC
Read the original article
Hit count: 193
JavaScript
|jQuery
Hello all,
I have this function below which returns all IDs of checked boxes on my page seperated by a comma. It works great but the problem is, it seems to put a lot of white space after each checkbox ID. I can't seem to figure out why?
/*Returns selected checkbox ID in string seperated by comma */
function get_selected_chkbox(){
var checked_string = '';
$('#report_table').find("input[type='checkbox']").each(function(){
if(this.checked){
checked_string = checked_string + this.id + ',';
}
});
alert(checked_string);//test1 ,test2 ,
return checked_string;
}
Thanks all for any help
© Stack Overflow or respective owner