Get ID of a Clicked Link
<p>In the code below and demo here <a href="http://jsfiddle.net/jasondavis/vp2YN/3/" rel="nofollow">http://jsfiddle.net/jasondavis/vp2YN/3/</a> you can see I need to get the ID attribute of a clicked item and assign it to a variable in Javascript.</p>

<p>Right now the code returns the ID name of the first item, regardless of which item is clicked on.</p>

<p>In the Javascript you can see I have this line commented out...</p>

<p><code>var clickedID = this.attr("id");</code>
when I use that line, I get an error saying: <code>Object has no method 'attr'</code></p>

<p>Please help me get the ID name of the clicked link and assign it to a variable </p>

<p>HTML</p>

<pre><code>&lt;a href="#" style="display:block" class="button insertcolumn" id="one_half"&gt;2 Columns&lt;/a&gt;

&lt;a href="#" style="display:block" class="button insertcolumn" id="one_third"&gt;3 Columns&lt;/a&gt;

&lt;a href="#" style="display:block" class="button insertcolumn" id="one_fourth"&gt;4 Columns&lt;/a&gt;​
</code></pre>

<p>Javascript/jQuery</p>

<pre><code>jQuery('.insertcolumn').click(function(){

    var clickedID = jQuery('.insertcolumn').attr("id");
    //var clickedID = this.attr("id");

    alert(clickedID);

});​
</code></pre>

<p>Demo <a href="http://jsfiddle.net/jasondavis/vp2YN/3/" rel="nofollow">http://jsfiddle.net/jasondavis/vp2YN/3/</a></p>
