Select the id of an element using jquery
<p>Following are the divs i have:</p>

<pre><code>&lt;div class="grey-column" id="infoblock1" data-type="datahere"&gt;&lt;/div&gt;
&lt;div class="green-column" id="infoblock2" data-type="datahere"&gt;&lt;/div&gt;
&lt;div class="red-column" id="infoblock3" data-type="datahere"&gt;&lt;/div&gt;
</code></pre>

<p>I am trying to find out the id of the element which has been clicked, I have this code: </p>

<pre><code>$(function(){
    $('.green-column, .red-column, .grey-column').click(function() { 
         id_clicked = this.id; 
         var id_final = '#';
         id_final += id_clicked;
         $("&lt;div&gt;" + $(id_final).attr("data-type") + "&lt;/div&gt;").dialog();
    });
});
</code></pre>

<p>So whenever a user clicks a div, the click function will be fired, and the id of the element clicked is found. But the attr() function doesn't seem to be working here. Please help me out. </p>
