javascript - Unable To Manipulate Newly Created DOM Elements -
i attempting add simple filtering page displays list of elements. elements displayed need filtered can changed user. javascript destroys , adds elements page based on users input. filtering function below works following page load ceases work in chrome , safari (but continues work in firefox) after user has changed setting , new elements have replaced original set.
function applyfilter(filter){ console.log(filter); var elements = $('.class'); switch(filter){ case 'free': $.each(elements, function(){ var element = $(this); if(element.find('.label-free').length){ element.removeclass('hide'); } else { element.addclass('hide'); } }); break; case 'lock': $.each(elements, function(){ var element = $(this); if(element.find('.label-free').length){ element.addclass('hide'); } else { element.removeclass('hide'); } }); break; default: elements.removeclass('hide'); } console.log(elements); }
i know code triggering @ appropriate time monitoring console. furthermore, output shows 'hide' class has been added , removed expected 'elements' object these changes not rendered within browser.
Comments
Post a Comment