Well, electors are chosen way before the election. And they have to be nominated. These electors usually 'pledge' their votes. So let's say I'm a Democrat and was nominated and gave my pledge to Obama, I would be presumed to be giving my vote to Obama.
However, you also have faithless electors. These are electors who vote against whom they pledged or refuse to vote.