Complete Code For Converting From Inches To Miles Using Javascript
<!DOCTYPE html> <html> <head> <title>How To Convert From Inches To Miles Using Javascript</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet"> </head> <style> body { background: darkslategray; } .form-control{ width:80%;!important; } </style> <body> <body> <div class="container"> <br/><br/> <div class="text-center"> <h1 id="color" style="color: white;">Convert From Inches To Miles Using Javascript</h1> </div> <div class="well"> <input type="text" id="inches"> inches = <span id="answer">?</span> Miles </div> <script> const inputBox = document.querySelector("#inches"); const answerParagraph = document.querySelector("#answer"); inputBox.addEventListener('input', report); function report() { const inches = inputBox.value; const miles = inches * 0.000015783; if (isNaN(miles)) { answerParagraph.textContent = '?'; } else { answerParagraph.textContent = miles; } } </script> </div> </div> </body> </html>