Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery not() working but throws 'unrecognized expression .' error
    primarykey
    data
    text
    <p>I have a set of elements which I'm filtering using some links. The elements have classes which define whether they should be shown/hidden when the links are clicked. Everything works, except I get this error on each click:</p> <blockquote> <p>Uncaught Error: Syntax error, unrecognized expression: . jquery.js?v=f7cfcab3b68cbd79eec30032754a6719:3</p> </blockquote> <p>It's something to do with my <code>.not()</code> selectors below. I've tried various alternatives (e.g. <code>:not</code>, and including/excluding single and double quotes, but nothing gets rid of the error:</p> <pre><code>var teamFilters = { dept: '', field: '' }, filter; $('.team-member-filters a').click(function() { var link = $(this); filter = $(this).attr('class'); if (link.parent().hasClass('active')) { link.parent().removeClass('active'); teamFilters[filter] = ''; } else { link.parent().addClass('active').siblings().removeClass('active'); teamFilters[filter] = $(this).attr('id'); } $('.main-body .team-member').animate({opacity: 1}, 250); $('.main-body .team-member').not('.' + teamFilters.dept).animate({opacity: 0.25}, 250); $('.main-body .team-member').not('.' + teamFilters.field).animate({opacity: 0.25}, 250); //console.log(teamFilters.dept); }); </code></pre> <p>The HTML for an individual element being filtered is:</p> <pre><code>&lt;div class="team-member secretariate reducing"&gt; &lt;div&gt; &lt;img src="/~climatex/files/cache/9d8d7862edc9f22dab5245926f79dace_f52.jpg" width="75" height="75" alt=""&gt; &lt;p class="name"&gt;Firstname Lastname&lt;/p&gt; &lt;p class="position"&gt;Job title&lt;/p&gt; &lt;/div&gt; &lt;a class="email" href="mailto:name@email.com"&gt;name@email.com&lt;/a&gt; &lt;a href="http://www.url.com" target="_blank"&gt;www.url.com&lt;/a&gt; &lt;/div&gt; </code></pre> <p>The <code>'.' + teamFilters.dept</code> selector is throwing the error, but since everything works I'm at a loss as to why.</p> <p>I've tried to concatenate the <code>'.'+teamFilters.dept</code> variable outside the <code>.not()</code> selector but it doesn't make any difference.</p> <p>I'm running jQuery 1.7.2.</p> <p>Any help appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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