using onclick to get Input value the right way

You may want to get an input value using onclick event listener, you then notice the value of the input element shows in element's values in console but not logging to console when clicked, this is simply because you are getting the value the wrong way.

You should be calling the value object inside the onclick event listener.

what i mean

const phone_number = document.querySelector("#phone_number")
//where phone_number is the id name of the input element

button.addEventListener("click", () =>{ 
    console.log(phone_number).value
})

Thanks For Reading, Please react if it was helpful.