It is possible to use regex in Javascript onclick event (HTML)?
<p>My question is quite simple but I cannot find the truth.
It is possible to use regex in Javascript <code>onclick</code> event (HTML)? <br>
For example is it possible to show div with different id but a same tag using regex :</p>
<blockquote>
<p>div s:</p>
</blockquote>
<pre><code>&lt;div class='zone' id='{{site.City}}'&gt;
&lt;div class='zone' id='{{site.City}}{{immo.CodeImmo}}'&gt;
&lt;div class='zone' id='{{site.City}}{{sth else}}'&gt;
</code></pre>
<blockquote>
<p>javascript regex :</p>
</blockquote>
<pre><code>onclick='$(&quot;#/^{{site.City}}./&quot;).show();'
</code></pre>
<p>I am worried about the regex syntax in the Javascript <code>onclick</code> event.<br>
Is it possible? and how is it possible to do it?<br>
This question is for my personal knowledge.</p>
<p><b>EDIT :</b><br>
ok I know now I can use:</p>
<pre><code>onclick=`$('div[id*=&quot;{{site.City}}&quot;]').show();`
</code></pre>
<p>but how can I do if <code>{{site.City}}</code> is a chain variable?<br>
What is the syntax for a loop in <code>onclick</code> even with a django dictionary variable?<br>
It's not the topic. It is still for my knowledge.</p>