Christopher
Christopher

Reputation: 2103

Link to activate form field

How can I make a form label activate (focus) the form field it coincides with?

Upvotes: 0

Views: 342

Answers (1)

Alastair Pitts
Alastair Pitts

Reputation: 19601

use the for attribute on the label. It references the id attribute of the form input/field you want it to focus.

eg. <input type="text" id="txt1" /><label for="txt1">Text 1</label>

Upvotes: 3

Related Questions