Can someone explain what the document.getElementById(\"demo\")
line does in the example below?
I understand getElementById gets the id of demo but the id is
the line
age=document.getElementById("age").value;
says 'the variable I called 'age' has the value of the element with id 'age'. In this case the input field.
The line
voteable=(age<18)?"Too young":"Old enough";
says in a variable I called 'voteable' I store the value following the rule :
"If age is under 18 then show 'Too young' else show 'Old enough'"
The last line tell to put the value of 'voteable' in the element with id 'demo' (in this case the 'p' element)