PART 2: HOw to use localStorage to create an array used to hide certain table rows...

PART 2: HOw to use localStorage to create an array used to hide certain table rows...

I have narrowed the code issues down to one last spot.  I can't seem to get the code rode to .hide() the table rows TR based on the localStorage values.  The following code creates the localStorage and then tries to hide the TR that contain the localStorage values.


thanks so much in advance for any advice.  I'll keep trying to figure it out but 

//THIS updates LOCALSTORAGE AFTER EACH CHECKBOX CLICK.  USE ON PAGE 1

$(document).ready(function () {

    $(":checkbox").click(function () {
        var arr = [];
        $("input:checkbox:checked").each(function () {
            arr.push($(this).parent().parent().parent().find('nobr').text());
        });
        localStorage.setItem('key', JSON.stringify(arr));

    });
    //THIS TRIES TO GET LOCALSTORAGE FROM ABOVE AND HIDE TR ELEMENTS WHOSE A ELEMENT TEXT VALUES ARE NOT PART OF ARRAY From PAGE 1

    $("#filter").click(function () {
        var arr1 = localStorage.getItem('key')
        alert(arr1);
        $(".s4-itm-cbx").each(function () {
            var attrText2 = $(this).attr("title");
            alert(attrText2);
            if (jQuery.inArray(attrText2, arr1) == -1) {
                $(this).parent().parent().hide();   //this hides all the TR and not just those in the localStorage
            }

        });
    });


});