The on () method is used as event handlers for the selected elements and child elements. We aim to learn about JavaScript change button text via example code. This is the text . how does south korea celebrate valentine's day. You can either pass in just a string (by default it changes the value of the confirm button), or an object. Explanation: Here, The script tag holds the javascript part. this code work for me var btn = document.getElementById("your_btn_id"); Listing Account: W3Schools Courses. About the different formats of images and multimedia files and their extensions. Here is the list of classes that you can use to give different sizes to your buttons. Note that you don't need to use document.getElementById("myButton1") inside change as it is called in the context of myButton1 -- what I mean by context you'll come to know later, on reading books about JS.