Got this code in the following question 嗨! 如何將此代碼轉換爲「通用」。目前它只適用於一種情況。如果我有兩個它不會工作。隱藏不同檢查比例的不同divs
謝謝
$(document).ready(function() {
$('input[type="radio"]').click(function() {
if($(this).attr('id') == 'watch-me') {
$('#show-me').show();
}
else {
$('#show-me').hide();
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="medium-12">
<label>Are you a member?</label>
</div>
<div class="medium-6">
<fieldset class="form-row" id="Member">
<input type="radio" id="watch-me" value="yes" name="Member" class="tap-input">
<label for="watch-me">Yes</label>
<input type="radio" id="MemberNo" value="no" name="Member" class="tap-input">
<label for="MemberNo">No</label>
<div id="show-me" class=" medium-12">
<div class="form-row">
<label for="memberNumber">Please enter your Membership number</label>
<input id="memberNumber" name="memberNumber" class="inputfield" type="text">
</div>
</div>
</fieldset>
</div>
使用類名來代替IDS – DaniP
通用:相對緩慢的過濾器表達式(
:radio
)僅在活動時間運行時(沒關係)? –什麼不起作用? – demo