Show a leading zero if a number is less than 10 - Javascript jQuery

Javascript examples for jQuery:Number

Description

Show a leading zero if a number is less than 10

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){//from  w  w w  . ja v a2  s. c  om
var number = 5;
var i;
if (number < 10) {
    console.log("0"+number);
}
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials