I'm using SharePoint 2013 to keep track of projects and their sub-tasks. But the view is getting pretty long and it would be nice to have a button to collapse all subtasks, leaving only the top-level parent tasks. Most to do lists have this functionality. I found a jQuery solution that didn't work, but I haven't found any other solutions. I'd rather not farm each project off to its own sub-site with it's own list.

  • 1
    its a strectxh but if you want to extend the front end functionality of the task list, load that snuppet or web part into a custom page layout with a div wrapper and ID, then use jquery to show and hide various sections.
    – klewis
    Commented Jan 30, 2016 at 19:56

1 Answer 1


I was also struggling with the jquery as it was getting looped.

Then found a response from Cristy on https://stackoverflow.com/questions/14542684/document-ready-function-being-called-over-and-over

To Use $(window).load

Below is the script.

Add it to Content Editor Webpart with in the script tag

function doCollapseTaskList() {
    $(".ms-commentcollapse-iconouter > img").each(function(){
$(window).load(function () {

Good Luck

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.