Javascript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Javascript

So I am trying to get a button to work using java script. When I type in text in my first name text box, I am trying to have the web page display the first name after I press the button. I have the Var $ = function(id) { return document.getElementById(id); }; function Submit () { document.write($(ā€œfirst_nameā€).textContent); } With first_name being the id for the text box and Submit being the onClick function and id ! Itā€™s not working though .. Any help would be great !

26th Sep 2018, 6:22 AM
Calvin
Calvin - avatar
2 Answers
+ 4
26th Sep 2018, 7:07 AM
CalviÕ²
CalviÕ² - avatar
+ 5
.value is used to get the input value.
26th Sep 2018, 6:53 AM
Toni Isotalo
Toni Isotalo - avatar