javascript - Filter list based on multiple classes u -


i'm trying .show() or .hide() li elements based on multiple classes selected out of array.

here example of html i'm working with:

<div class="category-list">   <ul class="light" id="category-menu">     <li id="client-x"><a class="work-item" onclick="togglecontent('client-x')">client x</a></li>     <li id="client-y"><a class="work-item" onclick="togglecontent('client-y')">client y</a></li>   </ul> </div> 

and function i'm calling:

function togglecontent(id) {   jquery(document).ready(function($) {     var ez = document.getelementsbyclassname(id);     var cats = [];         var items = window.localstorage.getitem('items');  if (items === null || items.length === 0) {       cats.push(id);     $(".port-project").hide();      localstorage.setitem("items", json.stringify(cats));     $(ez).closest(".port-project").show(); } else {     cats = json.parse(localstorage.getitem("items"));                    if (cats.indexof(id) > -1) {                 for(var = 0; < cats.length; i++){                                            if (cats[i] === id){                     cats.splice(i, 1);                     localstorage.setitem("items", json.stringify(cats));                     //$(ez).closest(".port-project").hide();                     }                    }                        } else {                                 cats.push(id);                 localstorage.setitem("items", json.stringify(cats));                 //$(ez).closest(".port-project").show();             }        } $(".port-project").filter(json.parse(localstorage.getitem('items'))).show(); } 

so i'm trying store of group of classes in array stored in localstroage. there when clicks on on filter want show or hide .port-projects based on items stored in localstorage, display projects include items in array (which accessed through json.parse/json.stringify). second if/else adding or removing classes based on whether class present or not.

i've read through countless threads , i'm trying use .filter feature check localstorage think i've mucked process. thoughts?

many in advance newbie.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -