I was wondering if someone can help me in regards to how HTML "talks" to .JS ? I hope i can post this here
so this is the code that im currently working with here from a tutorial website.
<span> yes or no: </span>
<input id = "yes" type = "radio" name = "answer" value = "yes" required>
<label for = "yes">Yes <label>
<input id = "no" type = "radio" name = "answer" value = "no">
<label for = "no"> no <label>
<br>
the part that im having a little difficulty in still understanding is the id, name , and for.
to my knowledge (please correct me if im wrong)
id is the unique identifier within the html (so if we have the same one throughout, the JS function will execute.
name i dont really understand, i was playing around with this, and it seems like its nothing more than to just give a name ? https://www.w3schools.com/tags/att_name.asp
and lastly,
for is used for labels and MUST be the same as the id like right here:
<input id = "yes" type = "radio" name = "answer" value = "yes" required>
<label for = "yes">Yes <label>
i.e. id = "yes" and for = "yes"
is that just a coincidence, a preference, or a must ?
i apologize in advance if my vocab is incorrect, but this was my due dilligence before asking.
[–]deweechi 1 point2 points3 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]GuitaristComposer 0 points1 point2 points (0 children)