You can use presence property to hide/ display the fields.
FieldName.presence = "visible"; // Display the field.
FieldName.presence = "hidden"; // Hides the field.
You can decide on the event you want to place the code in based on your requirements. Exit event will be executed when the user leaves the field. Change event will be executed when the value changes in the field.
Thanks
Srini