Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

buttons

/*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>


Source by www.edureka.co #
 
PREVIOUS NEXT
Tagged: #buttons
ADD COMMENT
Topic
Name
4+4 =