After JQ gets the tag element itself, it gets its own HTML text format (find only finds one level of child elements)

    var leftNavMenu = '';
    $('#leftNav').parent().find('ul[class*="layui-nav-tree"] > li[class*="layui-nav-item"]').each(function () {
        leftNavMenu = leftNavMenu + $(this).prop('outerHTML');
    });
    storageK.setItem("leftNav", leftNavMenu);

 

Read More: