onclick div colour should change
<p>Am having several boxes(more than 100) that will create dynamically with</p>

<pre><code>&lt;div id="window5"&gt;&lt;/div&gt;
&lt;div id="window18"&gt;&lt;/div&gt;
&lt;div id="window190"&gt;&lt;/div&gt;
</code></pre>

<p>Now If i click on one box the colour should be red,then if i click on the other box the colour should be changed to red(the first box colour should come to normal).I used some code like this,but it is not taking the css class.</p>

<p>How can i get the dynmic id of this case.</p>

<p>css file:</p>

<p>.selected{
    color: red;
}</p>

<p>used javasscript code as;</p>

<pre><code>    &lt;script type="text/javascript"&gt;

        $(document).ready(function () {

            $("div[id *= 'window']").click(function (e) {

                $(".selected").removeClass("selected");
                $(this).addClass("selected");
                e.stopPropagation();
            });
            $(document).click(function () {
                $(".selected").removeClass("selected");
            });
        });

    &lt;/script&gt;
</code></pre>
