Input value returns Null

Input value returns Null
0

#1

Trying to create something a button that can get the value in an element but i keep getting the error " Cannot read property ‘value’ of null"

I did some research and found out it’s because javascript loads before the HTML elements but from my logic, doesn’t my code only get the value of userInput after i click the search button?

This is my code: https://codepen.io/CodeMaster1998/pen/QmBjeb?editors=1010


#2

The issue is in the following line:

var userInput = (document.getElementById('#userInput')).value();

When using getElementById, do not include the # in front of the id name.

Also, value is not a function (it is a property), so you do not need the () at the end.