我网站上的用户可以填写不同主题的表单。如果他们填写其中一个科目,他们决定选择另一个科目,那就是他正在填写的科目。另一个打开了。但是当用户选择他在填写之前填写的相同主题时。我想要的是当用户决定选择旧的隐藏的另一个主题并清除其中的所有信息时。我的代码是这样的,但这非常简化:
<div class="steps">
<label for="example">Example</label>
<input type="text" name="inputexample" id="inputexample" />
</div>
而且,这是一个fiddle
答案 0 :(得分:0)
$('input[type=radio]').on('change', function(){
var class1=$(this).attr('class');
$('div').each(function(){
$('input[type=text]').val('');
if($(this).attr('id')==class1)
{
$(this).show();
}
else{
$(this).hide();
}
});
});
演示: