The superficial answer is that Democrats vote in the Democratic primary, and Republicans vote in the Republican primary. But that's both facetious and fails to address the full complexity of the situation.
There are fifty states, and each state has its own rules for how (and even if) primary elections are conducted in that state. The purpose of a primary is to decide who the party will name, or nominate, as its recommended candidate for some particular office. In a closed primary, only "members" of the party are permitted to vote.