jquery - Make sure that only one radio button is selected -


I need to check that only one radio button (in two) has been checked. Generally you add the same name = "some" to all radio buttons in the group, but in this case they do not have the same name - and unfortunately, I can not change it.

I have, but I do not know how to do this:

  var check 1 = $ ('#A') ; Var check2 = $ ('# two'); Var allChecks = check1, check2; AllChecks.change (function () {allChecks.each (function () {$ (this) .attr ('checked',! $ (This) .attr ('checked'));}); return false;});   

and:

  & lt; Input type = "radio" name = "one" id = "one" & gt; & Lt; Input type = "radio" name = "two" id = "two" & gt;    

You can do something without modifying your html:

  $ ("#A"). Change (function () {$ ("# 2") .prop ("check", wrong);}); $ ("# Two"). Change (function () {$ ("#in") .prop ("check", wrong);});    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -