getting id passed through a href link in click function
<p>I've got a fairly straight forward question. Why can't I use <code>$('a.view').attr('id')</code> (Ref //1 in code) in my click function? I tried it and it failed to work but <code>this.id</code> works. I guess I primarily want to know the difference in the context of the code below:</p>

<p><strong>displayRecord.php (The following link calls the click function):</strong></p>

<pre><code>echo '&lt;td&gt;&lt;a href="#" style="text-decoration: none;" id="'.$data['id'].'" class="view" &gt;&lt;input type="button" value="View" /&gt;&lt;/a&gt;&lt;/td&gt;';
</code></pre>

<p><strong>editTicket.php:</strong></p>

<pre><code>$('a.view').click(
            function(e) 
                {    
                             //1                    
                             var ticket_id = this.id;

                    dlg.load('displayRecord.php?id='+this.id, function(){                           

                    var escalationValue = '';

                    $.post('escalateValue.php',{post_ticket_id:ticket_id}, 
                    function(data) {

                        if (data == 'No'){
                            showCount();
                        }
                    });

                    dlg.dialog('open');

                });

            });
</code></pre>
