質問

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?

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top