Jquery Short-Hand Code For a Long List of Same Function
<p>I have an HTML structure like this below:</p>

<pre><code>List
&lt;ol id="years"&gt;
&lt;li class="2011"&gt;2011&lt;/li&gt;
&lt;li class="2012"&gt;2012&gt;&lt;/li&gt;
&lt;li class="2013"&gt;2013&gt;&lt;/li&gt;
&lt;/ol&gt;

News:
&lt;div class="news 2011"&gt;Some News here&lt;/div&gt;
&lt;div class="news 2012"&gt;Some News here&lt;/div&gt;
&lt;div class="news 2013"&gt;Some News here&lt;/div&gt;
</code></pre>

<p>I am in need of a short-hand code of the code below(It works, but i want it to be automated, not manual):</p>

<pre><code>$('.2011').click(function() {    
    $(".news").show().not('.2011').hide()
 return false;
        });

$('.2012').click(function() {    
    $(".news").show().not('.2012').hide()
 return false;
        });

$('.2013').click(function() {    
    $(".news").show().not('.2013').hide()
 return false;
        });
</code></pre>

<p>What i tried was:</p>

<pre><code>for(i=2011; i&lt;= 2020; i++){

$('.'+i+'').click(function() {    
    $(".news").show().not('.'+i+'').hide();
 return false;
        });
}
</code></pre>

<p>When i click on a li item, it just hides everything, so it is not the expected result.</p>

<p>Any help is appreciated.
Thanks for your time!</p>
