2

I am selecting radio button using jquery based on textbox length. when I first select radiobutton using prop, all working fine. but when I work with attr, strange thing happens with following scenario.

Scenario: When all radio button first unchecked, and I select radiobutton using jquery, it works

but If I select another radio button and try to select previous radio button, it remains unselected

Here is link for Prop (which working all fine):

jsfiddle.net/Lo3qn6q8/

Here is link for attr (which is not working):

jsfiddle.net/hpmhxkdx/

If you say prop is better than attr, then when we use attr not prop?

Ubiquitous Developers
  • 3,637
  • 6
  • 33
  • 78

1 Answers1

3

http://jsbin.com/xopobuhubi/edit?html,console,output

The problem is that "checked" is a property, not an attribute. http://www.w3schools.com/jsref/prop_radio_checked.asp

You have to set it with .prop() (or as a property lookup on Native HTMLElement).

blade091
  • 642
  • 4
  • 10