How to Hide or show List or Library control

Hi I would like to show/hide fields based on toggle.

the below code i tried is working if its text field but not for list and library control.

SPDataTable3 is the table i would like to hide

hideOrShow();
function hideOrShow() {

  if (fd.field('ProfessionalIndemnityInsurance').value) {
      $(fd.container('SPDataTable3').$parent.$el).show(); 
   } else {
       $(fd.container('SPDataTable3').$parent.$el).hide(); ; 
   }

}
fd.field('insuranceclaimslevied').$on('change', hideOrShow);
fd.field('ProfessionalIndemnityInsurance').$on('change', hideOrShow);

Hello @Rinu,

To hide/show List or Library control dynamically you need to:

  1. Give control a CSS class, e.g. 'table-to-hide'
    image
  2. And use this code to show/hide the control:
//hide control
$('.table-to-hide').hide();
//show control
$('.table-to-hide').show();

Please find more information about how to work with fields/control/containers in JavaScript here.

Thank you Mnikitina, was it the same for any controls such as RichText etc

Dear @Rinu,
Yes, you can use the following method for anything on the form. Moreover, you can give the same class to a number of cells, and hide multiple at the same time, like a group.