HTML + JavaScript beginner here.
I'm trying to getElementById, a number in my case. I can only achieve NaN, Undefined or some strange text about an object.
I want the element's number and return it with the power of 2. 144. Thank you!
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Test</title>
<script src="test.js"></script>
</head>
<body>
<p id="number">12</p>
<button id="button1" onclick="calcSquare()">Click here!</button>
</body>
</html>
function calcSquare() {
var a = document.getElementById('number').value;
var b = 2;
document.getElementById('number').innerHTML = (Math.pow(a, b));
}