JavaScript Can Change HTML Content
One of many JavaScript HTML methods is getElementById() and getElementByName.
The example below “finds” an HTML element (with id=”demo”), and changes the element content (innerHTML) to “Hello JavaScript”
Java Script works on a set of conditions, its said that when someone clicks on the demo button, it is something like this, then it has set its condition, when someone clicks on the button mentioned by you, then the java script will run and the function in it Your made will be displayed
Example for JS.
This code OUTPUT Show :-
What is favorite code
Output :-
What Can JavaScript Do?
JavaScript can change HTML attribute values.
In this case JavaScript changes the value of the src (source) attribute of an image.
Output
What Can JavaScript Do?
JavaScript can change the style of an HTML element.