Change text and background onclick issue

howdy,

i’m having an issue trying to get the background color and text to change when a button is clicked. the background, no problem. with the text, i need only the corresponding text to show depending on which button is clicked. the text stays after each button is clicked. here is the code on codepen. click A or B.
thank you!

https://codepen.io/drew-pear/pen/dyMdYGX

  function changeColor(color) { 
                document.body.style.background = color; 
            } 

You used this code here, couldn’t you just do the same for text color using an onClick and make it transparent?

thank you for your suggestion.
i tried this and it worked

        function changeColor(color) { 
            document.body.style.background = color; 
        } 
          
        function gfg_Run() { 
            changeColor('green'); 
            el_down.innerHTML = "Thank You";
            el_down2.innerHTML = ""; 
        }  
		function gfg_Run2() { 
            changeColor('red'); 
            el_down2.innerHTML = "No Thank You";
	        el_down.innerHTML = ""; 
        }
1 Like