How can I invisiblize groups of controls via jQuery?

前端 未结 3 873
情书的邮戳
情书的邮戳 2021-01-25 15:41

In my Sharepoint project/Web Part/Web Page, I dynamically create page elements/controls using C# in the *.ascx.cs file.

In the *.ascx file, I use jQuery for responding t

3条回答
  •  难免孤独
    2021-01-25 16:15

    there are a number of ways to do this. but in your jquery implementation I would decorate the elements with data tags that will tell the code which elements to hide and show.

    
    
    
    var $group1 = $('*[data-group="1"]');
    var $group2 = $('*[data-group="2"]');
    if (ckd) {
      $group1.hide(); 
      $group2.show(); 
    }
    else{
     $group2.hide(); 
     $group1.show(); 
    }
    

    You could do the same thing with css classes as well but I prefer using the data attribute

提交回复
热议问题