none
remove the table inside div using jquery RRS feed

  • Question

  • Dear all,

    I have a sharepoint 2013 site and enabled metadata navigation.I want to remove some columns in navigation using jquery.I have checked in developer tool i found div inside tables now i want to delete complete table.Using below code i can able to delete first and last columns but i want to delete the second or third columns.How to implement this please help.Thanks in advance.

     $('#ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeViewn0Nodes').find('table').first().find('tr').first().remove()

     $('#ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeViewn0Nodes').find('table').last().find('tr').last().remove()


     
    Tuesday, July 10, 2018 3:34 AM

Answers

All replies

  • Hi,

    You can use next()/prev() or :eq() selectors something like below.

    // To remove next row 
    $('#ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeViewn0Nodes').find('table').first().find('tr').first().next().remove()
    
    // To remove second row 
     $('#ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeViewn0Nodes').find('table').first().find('tr:eq(1)').remove()
    
    // To remove third row 
     $('#ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeViewn0Nodes').find('table').first().find('tr:eq(2)').remove()

    Regards.


    Tuesday, July 10, 2018 4:05 AM
  • Thanks for your reply jaydeep.Tried this no luck.
    Tuesday, July 10, 2018 4:58 AM
  • Can you paste your html here or screenshot so that i can understand html structure?
    Tuesday, July 10, 2018 5:29 AM
  • when iam checking in developer tool inside div I have 6 tables like below.

    <table cellpadding="0" cellspacing="0" style="border-width:0;">
          <tbody><tr>
           <td><div style="width:12px;height:1px"></div></td><td><a id="ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeViewn1" href="javascript:TreeView_PopulateNode(ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeView_Data,1,document.getElementById('ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeViewn1'),document.getElementById('ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeViewt1'),document.getElementById('ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeViewt1i'),' ,'30:FieldNameNode:1829e851-7c4f-456b-bc3c-4a6108e581c2:048b6f56-ee9b-4717-b5b0-fbe5c45ab228:f8e1db84-5bcb-43d3-a118-2ca74c35b620:30|ListNode|1829e851-7c4f-456b-bc3c-4a6108e581c2|048b6f56-ee9b-4717-b5b0-fbe5c45ab228|dc916a06-fa19-479a-8f88-1629f52ecad0','tf')"><img src="/_layouts/15/images/MDNCollapsed.png?re style="border-width:0;"></a></td><td><a href="javascript:_spNavigateHierarchy(this,'','30:FieldNameNode:1829e851-7c4f-456b-bc3c-4a6108e581c2:048b6f56-ee9b-4717-b5b0-fbe5c45ab228:f8e1db84-5bcb-43d3-a118-2ca74c35b620:30|ListNode|1829e851-7c4f-456b-bc3c-4a6108e581c2|048b6f56-ee9b-4717-b5b0-fbe5c45ab228|dc916a06-fa19-479a-8f88-1629f52ecad0','\u002fsites\u002fDev',true,'FieldNameNode', 'TreeField=abcd')" title="Filter items by id="ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeViewt1i" tabindex="-1"><img src="/_layouts/15/images/EMMTermSet.png?rev=44"" style="border-width:0;"></a></td><td class="ms-tv-item ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeView_2" style="white-space:nowrap;"><a class="ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeView_0 ms-tv-item ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeView_1" href="javascript:_spNavigateHierarchy(this,'','30:FieldNameNode:1829e851-7c4f-456b-bc3c-4a6108e581c2:048b6f56-ee9b-4717-b5b0-fbe5c45ab228:f8e1db84-5bcb-43d3-a118-2ca74c35b620:30|ListNode|1829e851-7c4f-456b-bc3c-4a6108e581c2|048b6f56-ee9b-4717-b5b0-fbe5c45ab228|dc916a06-fa19-479a-8f88-1629f52ecad0','\u002fsites\u002fDev\u002fDocumentArchival\u002fTasneeDocs',true,'FieldNameNode', 'TreeField=abcs')" title="Filter  id="ctl00_PlaceHolderLeftNavBar_ctl04_WebTreeViewt1" style="border-style:none;font-size:1em;">aaa</a></td>
          </tr>
         </tbody></table>


    Tuesday, July 10, 2018 5:35 AM
  • Do you want to remove table? If so, you can use 

    .find('table:eq(1)').remove()

    • Marked as answer by Praveenrangu Tuesday, July 10, 2018 6:37 AM
    Tuesday, July 10, 2018 6:09 AM