在單選按鈕上選擇是我試圖顯示一個div,但我無法使它工作。我的代碼:JavaScript單選按鈕和顯示
<input id="y" type="radio" name="experience" value="y"/>Yes
<input id="n" type="radio" name="experience" value="n"/>No
<style type="text/css">
.desc { display: none; }
</style>
<div id="yes" class="desc">
<p>You have Wielding Experience!</p>
</div>
<div id="no" class="desc">
<p>You have no Wielding Experience!</p>
</div>
<script type="text/javascript">
$(document).ready(function(){
$("input[name='experience']").click(function(){
if ($("input[name='experience']:checked").val() == 'y')
$("#yes").show();
});
});
</script>
我在哪裏出錯了?
拋棄'@',還有'name ='location''在您的HTML中輸入的位置? – mVChr 2012-03-18 12:50:33
放棄@的噢,那不存在了,我會編輯它 - 雖然同樣的問題! – gdrules 2012-03-18 12:51:57