I'm new to programming and currently learning javascript. I'm trying to test what I've learned so far using a payroll calculator, but my code is not working. I created a function that will be called when the user clicks a button; if I add the function inside the same HTML file, it works fine. When the function is in my external javascript file, the function doesn't work. I clicked on View Page Source to confirm the external javascript file was loaded and it was.
HTML CODE
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Payroll Calculator</title>
<meta name="viewport" contect="width=devide-width, user- scalable=no,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/myStyle.css">
</head>
<body>
<header>
<div class="container">
<div class="col-xs-12">
<h1>Payroll Calculator</h1>
</div>
</div>
</header>
<div class="container">
<section class="main row">
<article class="col-xs-12 col-sm-6 col-md-6">
<h3>Employee</h3>
<div class="input-group">
<span class="input-group-addon" id="firstName">First Name</span>
<input type="text" class="form-control" placeholder="First Name" aria-describedby="basic-addon1">
</div>
<br>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Last Name</span>
<input type="text" class="form-control" placeholder="Last Name" aria-describedby="basic-addon1">
</div>
<br>
<div class="input-group">
<span class="input-group-addon" id="rate-type">Rate Type </span>
 <input type="radio" name="optradio">Hourly
<input type="radio" name="optradio">Salary
</div>
<br>
<div class="input-group">
<span class="input-group-addon">Rate Amount</span>
<input type="text" class="form-control" aria-label="Amount (to the nearest dollar)">
<span class="input-group-addon">.00</span>
</div>
<br>
<label id="EnterHours" onclick="enterHours()">Enter Hours</label>
<br>
<p id="hours"></p>
<br>
<label id="EnterEarnings">Enter Earnings</label>
<br>
<p id="earnings"></p>
<br>
<button type="button" class="btn btn-default" onclick="enterHours()">Calculate</button>
<button type="button" class="btn btn-default">Cancel</button>
</article>
<aside class="col-xs-12 col-sm-6 col-md-6">
<h3 class="sidebar">Results</h3>
</aside>
</section>
</div>
<footer>
<div class="container" >
<h3>Andres Quintero</h3>
<p id="demo"></p>
</div>
</footer>
<script src="js/app2.js"></script>
</body>
Javascript Code
$(document).ready(function(){
function enterHours(){
document.getElementById("hours").innerHTML = "This is a test";
}
}