Monday, April 11, 2011

How to Exclusively Select Radio Buttons if name attribute is deprecated?

I learned that the name attribute has been deprecated. But this is how I performed exclusive selection of radio buttons on the form. How do I do it now without using JavaScript?

<input type="radio" name="gender" value="male">Male</input>
<input type="radio" name="gender" value="female">Female</input>
From stackoverflow
  • Undo your belief that the name attribute is deprecated.

    Name is deprecated on a, applet, frame, iframe, img and map but not on input.

  • I simply use jQuery and give all radio elements in same group some class. That way I can select elements with $("input.classname").

    Hippo : That's nice for you, but maybe not everybody uses jQuery....
    Stiropor : Oops, missread the last sentance. My bad :)
  • As far as I know, the name attribute is not deprecated in general, only for certain elements, namely a, applet, form, frame, iframe, img, and map. For those, you're supposed to use the id attribute instead. For input elements, using name is still correct.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.