Question


For this, use the document.getElementByClassName(). Following is the code −

Example

 Live Demo






Document









To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.

Output

This will produce the following output −

When you click the button, an alert message will be visible. This will produce the following output −

raja
Published on 10-Sep-2020 07:18:18

Not affiliated with Tutorialspoint