Change button text :- JavaScript


  • The value property sets or returns the value of the button value attribute.
  • In this example change the button value, when click the button.

  • Code:-

    1. <!DOCTYPE html> 
    2. <htm<html>l> 
    3.  
    4. <head> 
    5.  <meta name="viewport" content="width=device-width, initial-scale=1"> 
    6.  
    7.  <script> 
    8.   function chg_name() 
    9.   { 
    10.    document.getElementById('btn1').value = "I am New Name"; 
    11.   } 
    12.  </script> 
    13.  
    14. </head> 
    15.  
    16. <body> 
    17.  
    18.  <input id="btn1" value="Click TO change My Name" type="button" onclick="chg_name();"> 
    19.  
    20. </body> 
    21.  
    22. </html>
    Change button text :- JavaScript Change button text :- JavaScript Reviewed by Network security on November 13, 2019 Rating: 5

    No comments:

    Useful Information

    Powered by Blogger.