title: JavaScript Uncaught SyntaxError: Unexpected token ILLEGAL
body: <p>I tried to run below code but chrome showed <strong>Unexpected token ILLEGAL</strong> .
  Can anyone help ?</p>
  
  <p>When I click the button, it should add the  tag, and when it find <strong>images/1h.jpg</strong> it does not exist ,it should trigger <strong>onerror</strong>event and run <strong>function onc()</strong> to add some CSS and load another picture, but it didnt run <strong>function onc()</strong> and when I access console ,it shows <strong>Uncaught SyntaxError: Unexpected token ILLEGAL</strong> .</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button id='a' onclick="onc();"&gt;aaa&lt;/button&gt;
  &lt;div&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function onc(){
   var path1= 'images/1h.jpg';//Does not exist
   var path2= 'images/1s.jpg';//exist
   var tmp = "&lt;img src='"+path1+"' onerror='nofind(this,"+path2+");' /&gt; ";
   $('div').html(tmp);
  }</code></pre>
  </div>
  </div>
  
  I searched some answers, it seems caused by  "" or '', but I really don't know how to fix my code. Thanks.</p>