Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 128 - 2625 PortGPt V2.1
P. 128

    https://www

                          G.   Write a Javascript program to display the value attributes of the button after clicked
                               on it.

                               <html>
              https://www                                                                                                     https://www
                               <script>

                               function change() {

                                 document.getElementById("Btn").value = "Value is changed!";

                               }
              https://www                                                                                                    https://www
                               </script>

                               <body>

                               <p>Click on "My Button" to display its value attribute.</p>

                                <button id="Btn" name="B1" value="Button1"
                               onclick="alert(this.value)"> Button 1</button>

                                <p>Click on "Try Out" to change the value attribute of
                               "Button 1".</p>

                               <button onclick="change()">Try Out</button>

                                <p><b>Tip:</b> Click on "Button1" before and after you have
                               clicked on "Try Out".</p>

                               </body>

                               </html>
                               Output:

             https://www                                                                                                     https://www

                      126   Premium Edition-VIII
                      126
                              https://www

| 123 124 125 126 127 128 129 130 131 132 133 |