Dynamic change font size:- JavaScript


  • A function is called in button click which assign font size to the html element.
  • element.style.fontSize is used to change or assign the fontSize.



  • Code:-   
  • <!DOCTYPE html> 
  • <html> 
  •  
  • <head> 
  •  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  • </head> 
  •  
  • <body> 
  •  
  •  <div id="t_div">Normal Text</div> 
  •  
  •  <button type="button" onclick="set_size();">Change Size</button> 
  •  
  •  <script> 
  •   function set_size() 
  •   { 
  •    document.getElementById("t_div").style.fontSize = "40px"; 
  •   } 
  •  </script> 
  •  
  • </body> 
  •  
  • </html>
  • Dynamic change font size:- JavaScript Dynamic change font size:- JavaScript Reviewed by Network security on June 01, 2019 Rating: 5

    No comments:

    Useful Information

    Powered by Blogger.