jquery - on getting the value of a radio button -
i ask what's wrong code, seems legit me.
when select radio button, radiomininum
still remains 0
.
var radiominimum=0; $('#mmininum').click(function(){ if($(this).is(':checked')){ radiominimum = 1; alert(radiominimum); } else{ radiominimum=0; alert(radiominimum); } }); alert(radiominimum);
inside if-else radiominimum displays correctly. if checked,its 1. bottom alert-outside .click radiominimum still displays 0.
everything appears working expected:
var radiominimum = 0; $('#mmininum').click(function(){ if($(this).is(':checked')){ radiominimum = 1; console.log(radiominimum); } else{ radiominimum=0; console.log(radiominimum); } });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="checkbox" id="mmininum">minimum</input>
Comments
Post a Comment