Click Event and JavaScript Function to Change CSS Style

3 months ago
3

Learn how to handle click events on an HTML element using a JavaScript function. The lecture goes over how to change the CSS styles of an element when you click it.

You can add an onclick attribute to an HTML element to do something when it is clicked. The value of the attribute is the name of a function followed by parentheses.

A function is a set of instructions that can be executed when its name is called with parentheses.

One way of defining a function in JavaScript is by preceding its name with the function keyword. Any input parameters are contained within the parentheses. Write the statements after the open curly brace and before the corresponding closing curly brace.

Loading 1 comment...