 <p>Try this:</p> <pre><code>&lt;div class="buttons"&gt; &lt;a href="#" class="btn" index="0"&gt;Button 1&lt;/a&gt; &lt;a href="#" class="btn" index="1"&gt;Button 2&lt;/a&gt; &lt;a href="#" class="btn" index="2"&gt;Button 3&lt;/a&gt; &lt;/div&gt; &lt;div class="text"&gt;&lt;/text&gt; var arr = ['First', 'Second', 'Third.']; $(".btn").on('click', function (e) { var index = $(this).attr("index"); $(".text").text(arr[index]); }); </code></pre>