Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

html

/*when you Click on these buttons it should call the function changeColor
and the function will change the color  */

    <button onclick="changeColor(this, 'red')">
      Click me to change my color.
    </button>

    <button onclick="changeColor(this, 'blue')">
        Click me to change my color.
      </button>

      <button onclick="changeColor(this, 'green')">
        Click me to change my color.
      </button>

    <script>
      function changeColor(element, color) {
        element.style.color = color;
    }
    </script>


 
PREVIOUS NEXT
Tagged: #html
ADD COMMENT
Topic
Name
2+6 =