如果你不介意的話,幫助不大。jQuery顯示/隱藏單選按鈕更改頁面加載
基本上,我有3個收音機和一個div。當第三個單選框被選中時,div應該可見。但是,當頁面加載時可以檢查廣播框,因此如果選中第三個框,則需要顯示div,否則應該最初隱藏,但如果稍後檢查第三個框,則可以看到它。
HTML:
<input type="radio" name="image_location" value="featured_image" />
<input type="radio" name="image_location" value="all_images" />
<input type="radio" name="image_location" value="custom_field" />
<div id="image_location_custom_field">
** Content **
</div>
在那裏我已經使用JavaScript走到這一步:
jQuery('input[name=image_location]').hide();
jQuery('input[name=image_location]').change(function() {
var selected = jQuery(this).val();
if(selected == 'custom_field'){
jQuery('#caption_custom_field').show();
} else {
jQuery('#caption_custom_field').hide();
}
});
非常感謝
謝謝,工作得很好。 – OzTheGreat