javascript - Target last visible div after js action? -
is possible target last visible div/container after js function has worked, in case mixitup plugin. click filter results, adds display: none
or display: inline-block
appropriate containers.
using code another stack question
$(function () { var $items = $($(".partners_list.container article.mix").get().reverse()); $items.each(function () { if ($(this).css("display") != "none") { $(this).addclass("red"); return false; } }); });
it works when page first loads, after active mixitup , filter results doesn’t add class red last ‘visible’ container assume because loaded , done job..
the mix function follows..
$(function(){ var $filterselect = $('#filterselect'), $container = $('#partner_container'); $container.mixitup({ animation: { enable: false } }); $filterselect.on('change', function(){ $container.mixitup('filter', this.value); }); });
so need fire based on when display: none
, display:inline-block
appears , disappears on page.
thanks shodaburp i’ve managed figure out callback function, god knows how must fluke.
the full code have , seems work...
$(function(){ var $filterselect = $('#filterselect'), $container = $('#partner_container'); $container.mixitup({ animation: { enable: false }, callbacks: { onmixend: function(state){ var $items = $($(".partners_list.container article.mix").get().reverse()); $items.each(function () { if ($(this).css("display") != "none") { $(this).addclass("red"); return false; } }); } } }); $filterselect.on('change', function(){ $container.mixitup('filter', this.value); }); });
Comments
Post a Comment