Html代碼是
<label><input type="radio" name="proofing" value="1">打樣</label> <label><input type="radio" name="proofing" value="0" checked="checked">不打樣</label>
jqury代碼是
$("input:radio[name='proofing']").change(function (){ //撥通 var value = $("input[name='proofing']:checked").val(); alert(value); if (value == 0) { $(".proofing-hide").show(); } else { $(".proofing-hide").hide(); } });
這裏注意javascript
var value = $("input[name='proofing']:checked").val();
我用java
<pre name="code" class="javascript"><pre name="code" class="javascript">var value = <span style="font-family: Arial, Helvetica, sans-serif;">$("input:radio[name='proofing']")</span><span style="font-family: Arial, Helvetica, sans-serif;">.val(); </span>獲取到的始終是1