terça-feira, 19 de maio de 2015

Codigo para trocar palavra de cor - Javascript

<!DOCTYPE html>
<html>
<head>
  <title>getElementById example</title>
  <script>
  function changeColor(newColor) {
    var elem = document.getElementById("para1");
    elem.style.color = newColor;
  }
  </script>
</head>
<body>
  <p id="para1">Hi!</p>
  <button onclick="changeColor('blue');">blue</button>
  <button onclick="changeColor('red');">red</button>
    <button onclick="changeColor('yellow');">yellow</button>
    <button onclick="changeColor('brown');">brown</button>
    <button onclick="changeColor('black');">black</button>
    <button onclick="changeColor('white');">white</button>
</body>
</html>

Nenhum comentário:

Postar um comentário