How to create dynamic id selector in Jquery?
<p>My php code goes something like this way- </p>

<pre><code>for($i=1;$i&lt;=$n;$i++)
{
$id='selectThisID-' . $i;
?&gt;
&lt;div id="&lt;?php echo $id;?&gt;"&gt;On Select this Div(say #selectThisID-3)&lt;?php echo $field-n; ?&gt;&lt;/div&gt;

&lt;?php $id= 'paraID-' . $i;
&lt;p id="&lt;?php echo $id; ?&gt;" style="display:none"&gt;Toggle this para(say #paraID-3) for selected ID only&lt;/p&gt;
}
</code></pre>

<p>Now how can I handle this variable number of id's in my jquery. As I know for single div 
statement it could be-</p>

<pre><code>    &lt;script&gt;
        $(document).ready(function(){
            $("[id^=selectThisID-]").click(function(){
                $("[id^=paraID-]").toggle();
            });
        });
&lt;/script&gt;
</code></pre>

<p>So on selecting element with id <code>'#selectThisID-1'</code>, <code>&lt;p&gt;</code> will toggle. How can I use <code>#selectThisID-2, #selectThisID-3....#selectThisID-n</code> as jquary selector. How can I get value of 'n' from php code to JQuery? Please help. Thanks in advance.</p>

<p>Edit-
Suppose <code>$n=5</code>, so there are total 5 <code>div</code> elements. Now the problem is that when I select any of <code>div</code>(say <code>#selectThisID-3</code>) all <code>&lt;p&gt;</code> elements get toggled(i.e. <p> with <code>#paraID-1, #paraID-2....#paraID-5</code> all toggled). However I need to toggle para-3 when div-3 selected, toggle para-4 when div-4 selected and so on. Please help.</p>
