0

Javascript text input value

Hi everyone, If I have a code in html that goes like: <input type="text" onchange="change()"> (There are a few line like this in the script) Is there any way in javascript to reach the input's value without using getElementByWhatever? I mean something like: <input type="text" onchange="change(this)"> function change(input) { alert(input.val()); } So that if I change the value of the text input, it will immediately alert the new value.

14th Nov 2018, 3:51 PM
Yoni Simian
1 Réponse
+ 2
Nevermind, I found it... It turns out that I should've use input.value instead of input.val(). Took me quite a lot of time to figure this out...😅
14th Nov 2018, 8:02 PM
Yoni Simian