jquery - Keep detection of value selected in radio button -


The code below throws a warning upon loading, because it detects that the second radio button is checked but If I select the first one, and then select the second, the warning does not throw away .. Why?

  & lt; Input type = "radio" id = "s530351a84b2aa_tipo_0" name = "radioName" required = "required" value = "0" & ​​gt; & Lt; Input type = "radio" id = "s530351a84b2aa_tipo_1" name = "radioName" required = "required" value = "1" check = "check" & gt; $ (Document) .ready (function () {if ($ ("input [name = radioName]: checked"). Val () == 1) {alert ("fajslf"}}}});  

This is because you do not capture any event, just this Check that you have been checked on certain Andean document load . You need to capture the change event of your radio button in the following code:

  $ ("input [name = radioName]"). ("Change", function () {if ($ ("input [name = radioName]: checked"). Val () == 1) {warning ("fajslf")}}});  


Comments