Can HTML5 form shortcuts be used without global leakage?

The HTML 5 standard form label requires an identifier to associate the label with input .

<form> <label for="male">Male</label> <input type="radio" id="male"/> <label for="female">Female</label> <input type="radio" id="female"/> </form> 

As most JS developers know, using globals leak identifiers - in this case window.male and window.female are created.

How to use form shortcuts without creating global tables?

+7
javascript html5 forms
source share
1 answer

use another way:

 <form> <label>Male <input type="radio"></label> <label>Female <input type="radio"></label> </form> 
+10
source share

All Articles