我有4个单选按钮。如果我点击1个单选按钮,则应打开1个div 如果点击第二个单选按钮,则应打开第二个数字...
这是我的单选按钮代码
<div class="fLeft">
<div class="clear"><input type="radio" name="ResumeEmail[cv_format]" value="pdf" id="ResumeEmail_cv_format_0"><label for="ResumeEmail_cv_format_0" style="padding-top:0px;">PDF</label></div><br>
<div class="clear"><input type="radio" name="ResumeEmail[cv_format]" value="word" id="ResumeEmail_cv_format_1"><label for="ResumeEmail_cv_format_1" style="padding-top:0px;">WORD</label></div><br>
<div class="clear"><input type="radio" name="ResumeEmail[cv_format]" value="rtf" id="ResumeEmail_cv_format_2"><label for="ResumeEmail_cv_format_2" style="padding-top:0px;">RICH TEXT</label></div><br>
<div class="clear"><input type="radio" name="ResumeEmail[cv_format]" value="custom" id="ResumeEmail_cv_format_3"></div> </div>
我得到的答案
<script type="text/javascript">
$(document).ready(function() {
// do stuff when DOM is ready
$('#ResumeEmail_cv_format_0').click(function() {
var checked = $(this).attr('checked', true);
if(checked)
{
$("#view_resume").show();
}
else
{
$("#view_resume").hide();
}
});
});
</script>
现在我知道如果我点击第一,第二和第三个单选按钮中的任何一个。该div应该打开其他不是
答案 0 :(得分:2)
$("#div1").hide();
$("#div2").hide();
$('#radiobutton1').click(function() {
var checked = $(this).attr('checked', true);
if(checked)
{
$("#div1").show();
}
else
{
$("#div1").hide();
}
});
$('#radiobutton2').click(function() {
var checked = $(this).attr('checked', true);
if(checked)
{
$("#div2").show();
}
else
{
$("#div2").hide();
}
});