Help with jQuery if statement
<p>I have a paging system implemented for user comments and depending on which page you have clicked on I want to only show 3 page numbers in each direction. So if you clicked on page 6 then only show pages 2 - 9, so 7 total.</p>

<p>I have my html like so:</p>

<pre><code>&lt;div id="paging"&gt;
&lt;span id="1" class="page"&gt;&lt;/span&gt;
&lt;span id="2" class="page"&gt;&lt;/span&gt;
&lt;span id="3" class="page"&gt;&lt;/span&gt;
&lt;span id="4" class="page"&gt;&lt;/span&gt;
and so on...
&lt;/div&gt;
</code></pre>

<p>jQuery/javascript like so:</p>

<pre><code>$(".page").click(function() {
        var clicked = $(this).attr("id");

        var parent = $("#paging span");
        $(parent).each(function() {
            if($(this).attr("id")+ 3 &gt;= clicked)
            $(this).removeClass("hidden");
            else
            $(this).addClass("hidden");
            });
});
</code></pre>

<p>So far all it does is apply the hidden class to any page numbers before the currently clicked one.</p>
