jeudi 21 septembre 2017

Toggle divs based on checkbox values regex

I'm trying to toggle divs based on checkbox value by regex

i put unique id as data-row-id and using that value i 'm trying to hide and show divs here is my regex

new RegExp("^" + $("input[type='checkbox'].filter-industry:checked").map(function () { return $(this).data("rowId"); }).get().join("|") + "$");

then i do this

$("div.industry-ri-box").each(function () { var $this = $(this); $this[rowIds.source !== "0" && rowIds.test($this.data("rowId")) ? "fadeIn" : "fadeOut"](); });

it seems work perfects but for some combination it messing up. i know something wrong with regex but couldn't figure it out please help me to check identify the bug. i got this way by following stackoverflow answer unfortunately i couldn't find it for reference sorry about that.

here is the sample codepen for the that

regards




Aucun commentaire:

Enregistrer un commentaire