title: Jquery Uncaught Error: Syntax error, unrecognized expression, Can I detect and skip it?
body: <p>I am looking at data in two list. The first list has bad data and throws Uncaught Error: Syntax error, unrecognized expression. </p>
  
  <p>How can I check for this bad data and continue with my code execution? Another option maybe log the error and continue?</p>
  
  <p>Is there some way to detect a error in general or would I have to check the data for each character?</p>
  
  <p>Two html lists. </p>
  
  <pre><code>//$("#listOne &gt; li").first(); has the bad data in the data-info attribute.
  
  &lt;ul id="listOne"&gt;
     &lt;li data-info="a/[%ref%*]" data-infoTwo="x"&gt;One&lt;/li&gt;
     &lt;li data-info="b" data-infoTwo="y"&gt;Two&lt;/li&gt;
     &lt;li data-info="c" data-infoTwo="z"&gt;Three&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;ul id="listTwo"&gt;
     &lt;li data-info="a"&gt;One&lt;/li&gt;
     &lt;li data-info="b"&gt;Two&lt;/li&gt;
     &lt;li data-info="d"&gt;Four&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Jquery</p>
  
  <pre><code>$('#listOne li').each(function () {
     $("#listTwo li[data-info=" + $(this).data("info") + "]").data("infoTwo", $(this).data("infoTwo"));              
  });
  </code></pre>