Escaping forward slash ("/") while using JavaScript to change CSS class
<p>I need to add some CSS class based on some condition using JavaScript but facing issue in case my string contains a forward slash (<code>/</code>). This is what my use case is</p>

<pre><code>&lt;div id="div_product-size-icon-121NM/L" class="disabled"&gt;&lt;/div&gt;
&lt;script&gt;
var newProductCode = '121NM/L';
 if(  newProductCode.contains('/') ){
       newProductCode = newProductCode.replace('/','/\//');
       $('#'+'div_product-size-icon-'+newProductCode).addClass('active');
    }
&lt;/script&gt;
</code></pre>

<p>I have even tried  <code>newProductCode.replace('/','/\');</code> but while running code, I am facing following error </p>

<blockquote>
  <p>JavaScript error: SyntaxError: unterminated string literal</p>
</blockquote>

<p>I can not change HTML along with product code; the option for me is to change it in JS.</p>

<p>Here is a working js example: <a href="http://js.do/code/90166" rel="noreferrer">JS code</a> </p>