Pregunta

Regarding forms with labeled fields, this (out-dated) jQuery Mobile documentation states:

Be sure to pair them properly with label elements via the for attribute.

The for attribute still exists in the latest version, but the current documentation does not even mention it anymore. What is it used for? Some sort of form validation?

¿Fue útil?

Solución

It's standard HTML (not jQm-specific) used to link text with a corresponding input element.

MDN Docs for <label>

Example:

<label for="your_name">Your Name:</label>
<input id="your_name" value="John Smith" />

When I tap on the label, the input text will gain focus. The for attribute should be set to the ID of the input element.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top