我网站上的用户可以用不同的主题填写表格。如果他们填写其中一个主题,并且他们决定选择另一个他正在填写的主题。然后另一个打开。但是,当用户选择自己填写的同一主题之前,仍然要填写。我想要拥有的是,当用户决定选择另一主题时,旧主题隐藏并清除其中的所有信息。我的代码是这样的,但是非常简化:
<div class="steps">
<label for="example">Example</label>
<input type="text" name="inputexample" id="inputexample" />
</div>
而且,这是fiddle
$('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();
}
});
});
演示: