[jQuery] checkbox array

[jQuery] checkbox array


Been losing my hair on this.
I'm trying to assign my checkbox array to a variable that I can send
through a post. But I the variable 'tempy' is always undefined. I must
be confused on how to reference an array, or maybe there is a better
way to do this?
js:
var tempy = $('input[name=foo]:checked').val();
html:
<input type="checkbox" name="foo[]" value="klaybul1" />
<input type="checkbox" name="foo[]" value="klaybul2" />
<input type="checkbox" name="foo[]" value="klaybul3" />
Thanks in advance!