Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery using find() with dynamic string
    text
    copied!<p>My question is how do I use the jquery find(), to find the correct listitems based on my checked checkboxes? I have tried building the string dynamicly but it does not work...?!</p> <p>Is there an easier way?</p> <p>I several listitems and a couple of checkboxes marked up like this.</p> <pre><code> &lt;li class="item" data-id="2" data-type="Bokföringsprogram" operativsystem='Windows' &gt; &lt;li class="item" data-id="2" data-type="Bokföringsprogram" operativsystem='Windows' operativsystem='MAC OS' &gt; &lt;li class="item" data-id="67" data-type="Faktureringsprogram" operativsystem='Windows' operativsystem='MAC OS' &gt; &lt;li&gt;&lt;input type="checkbox" name="boxvalidator" value="Windows" /&gt;Windows&lt;br /&gt;&lt;/li&gt; &lt;li&gt;&lt;input type="checkbox" name="boxvalidator" value="MAC OS" /&gt;MAC OS&lt;br /&gt;&lt;/li&gt; &lt;li&gt;&lt;input type="checkbox" name="boxvalidator" value="Ubuntu" /&gt;Ubuntu&lt;br /&gt;&lt;/li&gt; &lt;li&gt;&lt;input type="checkbox" name="boxvalidator" value="Linux" /&gt;Linux&lt;br /&gt;&lt;/li&gt; </code></pre> <p>Jquery code</p> <pre><code>$('input:checkbox[name="boxvalidator"]:checked').each(function() { $boxchecked = $boxchecked + ",li[operativsystem=~" + $(this).attr('value') + "],"; }); var $filteredPortfolio = $portfolioClone.find($boxchecked); </code></pre> <p>String looks like this: undefined,li[operativsystem=~Windows],,li[operativsystem=~MAC OS],</p> <p>must be an easier way of doing this?</p> <p>Cheers &amp; thanks for reading all the way down here!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload