How do I get the <input>
's Value
- I'm trying to make a page viewer through the iframe, so. I have searched up some things to help. But nothing has correctly done something to help. I've tried
Codes I used that didn't work.
Found on W3Docs, I used this portion of a code...
function getInputValue() {
// Selecting the input element and get its value
let inputVal = document.getElementsByClassName("inputClass")[0].value;
// Displaying the value
alert(inputVal);
}
<input type="text" placeholder="Type " id="inputId" class="inputClass">
<button type="button" onclick="getInputValue();">Get Value</button>
It didn't properly alert the value of the input.
I also tried this, its supposed to have a variable inside of a function that I can simply put inside a button's onclick
var input = document.getElementById("input_id").value;
this also failed in return. nothing happened when I put it inside of a button.
Additional
Is there any source I can find things like this?