Javascript examples for DOM Event:onclick
Handle onClick event to do text change
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <p id="peep"></p> <button onclick="myFunction('Harry Potter')">Click for Harry Potter</button> <button onclick="myFunction('Bob')">Click for Bob</button> <script> function myFunction(name)/*w w w.j a va 2 s.com*/ { document.getElementById("peep").innerHTML = "Welcome " + name; } </script> </body> </html>