Js para cambiar fondo con un click
<style>
#cuadro{ width:100px; height:100px}
</style>
<button id='cambiar1'>verde
</button>
<button id='cambiar2'>amarillo
</button>
<div id='cuadro'>hola mundo
</div>
<script>
document.getElementById('cambiar1').addEventListener('click', function(){
document.getElementById('cuadro').style.backgroundColor = 'green';});
document.getElementById('cambiar2').addEventListener('click', function(){
document.getElementById('cuadro').style.backgroundColor = 'yellow'});
</script>
Osea podes hacer el evento en el js o desde la etiqueta onclick='x' desde el html
ResponderBorrar