Questions tagged [for-attribute]

6 questions
453
votes
7 answers

What does "for" attribute do in an HTML

I wonder what is the difference between the following two code snippets: and
jeff
  • 13,055
  • 29
  • 78
  • 136
4
votes
2 answers

WPF label counterpart for HTML "for" attribute

Is there some attribute in WPF that I can add to element, so when I click it the target control get focus? The closest thing I have found is 'Target', but it works only with access keys and clicking it has no effect.
alex2k8
  • 42,496
  • 57
  • 170
  • 221
4
votes
1 answer

Click on label does not focus input despite for=id

I stumbled upon an interesting problem today and can't seem to solve it. I have three forms on my site, they all contain the same form fields. I have labels for each input field and would like to focus the text input (or in case of the radio buttons…
etoka
  • 41
  • 1
  • 3
3
votes
4 answers

Setting for attribute of a label element with object oriented method

Labels have a 'for' attribute which makes them point to a certain input field. I need to change the value of this attribute with JQuery so I could use: $("label").attr("for", "targetName"); But I also need to set the className, so i'd prefer to…
Martin
1
vote
2 answers

why do I need to bind checkbox with a label?

I got a quick question here. Why do we always bind a checkbox id to the for-attribute in a label? Does it have any purpose? If so, can you please list it out? And also its technical advantage. Thanks in advance, Madhu.
Madhu Sharan
  • 68
  • 1
  • 9
0
votes
3 answers

Get value from html label assiociated with radiobutton using FOR attribute

A html form with radio buttons which is assiociated with HTML label which looks like this.

sudhakarssd
  • 431
  • 4
  • 11
  • 25