0

I have a checkbox with id=officialCheckBox. And when I check and uncheck it I want to do somethings. Problem is with my code below, that although it runs the function once for each element in my list dataCollection (once i check and uncheck the checkbox), it only prints out the last data in the dataCollection all the time. I'm not sure why.

    var data;
    function printOut(dataCollection){
    for (var i = 0; i < dataCollection.length; i++) {
        data = dataCollection[i];
        $("#officialCheckBox").click(function(table,column){
            console.log(data);//This prints out the last element in dataCollection for every element in that collection
        });
    }
}
anders
  • 1,535
  • 5
  • 19
  • 43

0 Answers0