我有一个如下的javascript:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<li>
<input type="radio" class="gal_location" name="gal_location" value="0"> All
</li>
<li>
<input type="radio" name="gal_location" class="gal_location" checked="checked" value="11">Sivasagar</li>
<li>
<input type="radio" name="gal_location" class="gal_location" value="3">Guwahati</li>
<li><input type="radio" name="gal_location" class="gal_location" value="9">Jorhat</li>
<script>
if($('.gal_location').is(':checked')) {
var location_id = $("input:radio[name=gal_location]").val();
}
alert('Location id is '+location_id);
</script>
现在我希望收到Location id is 11
的提醒,但我会收到Location id is 0
的提醒
答案 0 :(得分:6)