Originally Posted by spacehead
Age:<input id="age" value="18" />
<button onclick="myFunction()">Try it</button>
age=document.getElementById("age").value; what does .value mean?
voteable=(age<18)?"Too young":"Old enough"; Why are you using the age variabel here?
Yes this isn't very helpful.
Unless your question is those bits in bold but still not very helpful.
The answers are: .value simply gets the value of the element you are looking for.
Why use the age variable? Well technically you don't have to you could just say:
voteable=(document.getElementById("age").value<18) ?"Too young":"Old enough";
But sometimes for readability of code it's a good idea to use variables.