[Tex/LaTex] Change color of an item in beamer when moving to next time

beamer

I have three items in a beamer slide. They appear one after the other when I press next.
My problem is I want the first two items to change color when the third item appears. Please explain how to do this.

Best Answer

No need to write everything twice, you can simply use \only<>{} to change the colour

\documentclass{beamer}

\begin{document}

\begin{frame}
        \begin{itemize}[<+->]
            \item \only<3>{\color{red}}1
            \item \only<3>{\color{red}}2
            \item 3
        \end{itemize}
\end{frame}

\end{document}  

enter image description here


To address the command about dvipsnames

Since beamer internally already loads the xcolor package you can pass the dvipsnames like this:

\documentclass[xcolor=dvipsnames]{beamer}

\begin{document}

\begin{frame}
        \begin{itemize}[<+->]
            \item \only<3>{\color{Peach}}1
            \item \only<3>{\color{Peach}}2
            \item 3
        \end{itemize}
\end{frame}

\end{document}  
Related Question