I have a <p>element that should contain whatever is written in the <input> box. The <p> does contain everything there is in <input> except the last character.
For example, (not valid JS code)
if input = Fish
then p = Fis
if input = Monster
then p = Monste
Here is my code
<head>
<script>
window.onload = function()
{
document.querySelector('input').addEventListener('keydown', function()
{
document.querySelector('p').innerHTML = document.querySelector('input').value
});
}
</script>
</head>
<body>
<p></p>
<input type="text" />
</body>
How do I make the p element contain even the last character in the input?