I want to log some information if the input value is a number. However, I am facing an issue where it's not working and no bugs are appearing.
Here is a snippet of code from CodePen (https://codepen.io/matoung/pen/KBNmPP)
let button = document.querySelector('.buttonClass');
button.addEventListener('click', function() {
let myValue = document.querySelector('.inputClass').value;
if(typeof myValue === 'number'){
console.log('This is a number');
}
});
.wrapper {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
}
.container-6 {
border: 1px solid #000;
align-items: center;
padding: 40px;
margin-top: 100px;
}
<html>
<head>
<title>Random</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="utf-8">
</head>
<body>
<input type="text" class='inputClass' />
<input type="button" value="Send" class="buttonClass"/>
<div class="wrapper">
<div class="container-6">
<p>It will be a number</p>
</div>
<div class="container-6">
<p>It will be a string</p>
</div>
<div class="container-6">
<p>It will be a boolean</p>
</div>
<div class="container-6">
<p>It will be an array</p>
</div>
<div class="container-6">
<p>It will be an undefined</p>
</div>
<div class="container-6">
<p>It will be a null</p>
</div>
</div>
<script type="text/javascript" src="script.js"></script>
</body>
</html>