如何删除同一Web部件列表中所有出现的标题

问题描述 投票:0回答:1

我有一个SharePoint页面,其中显示15个不同的列表,并且有一个名为Links的列表,我希望从这三个事件的前两个中删除标题。我只有的代码删除了传入列表的首次出现。

在页面上,我包括以下内容。下面的代码仅删除“链接和联系人”首次出现的标题。

<script type="text/javascript" data-lists="Links, Contacts, Links" src="../SiteAssets/js-enterprise/HideHeaders.js"></script>

我的脚本如下:

$(document).ready(function() {  

    // Get a list of views to turn off the headers
    var this_js_script = $('script[src*=HideHeaders]');
    var lists = this_js_script.attr('data-lists'); 

    var str_array = lists.split(',');

    for(var i = 0; i < str_array.length; i++) {
       // Trim the excess whitespace.
       str_array[i] = str_array[i].replace(/^\s*/, "").replace(/\s*$/, "");
       // Add additional code here, such as:
       //alert(str_array[i]);
       $("table[summary='"+str_array[i]+"'] tr:eq(0)").hide();
    }
});
javascript sharepoint-2013
1个回答
0
投票

如下修改JavaScript代码。

$(document).ready(function() {  
    // Get a list of views to turn off the headers
    var this_js_script = $('script[src*=HideHeaders]');
    var lists = this_js_script.attr('data-lists'); 

    var str_array = lists.split(',');

    for(var i = 0; i < str_array.length; i++) {
        // Trim the excess whitespace.
        str_array[i] = str_array[i].replace(/^\s*/, "").replace(/\s*$/, "");
        // Add additional code here, such as:
        //alert(str_array[i]);
        $("table[summary='"+str_array[i]+"']>thead").each(function(){
            $(this).hide();
        });
    }
});
© www.soinside.com 2019 - 2024. All rights reserved.