I'm working on a project in which I have to toggle the visibility of a <div>
.
I've got the following code:
<input type=radio name=type value=1> Personal
<input type=radio name=type value=2> Business
<div class=business-fields>
<input type=text name=company-name>
<input type=text name=vat-number>
</div>
I would like to togle the business-fields div. So, if none of the radio buttons, or the 'personal' radio button is selected: The div should be hidden. If the 'business' radio button is selected, I want it to show.
Currently, I am using this code:
$(input[name='type']).click(function() {
var status = $(this).val();
if (status == 2) {
$(.business-fields).show();
} else {
$(.business-fields).hide();
}
});
However, I was wondering if I can do this using the .toggle() function.