Why doesn't my code using jQuery hasClass() work?
<p>I am using hasClass method in my script but it is not working the way I want . 
My HTML table looks like this </p>

<pre><code>&lt;table id="sort"&gt;
            &lt;tr class="nodrag nodrop"&gt;
                &lt;td colspan=3&gt;&lt;strong&gt;&lt;a style="cursor:pointer;" class="toggle"&gt;Group 1&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;
                &lt;td style="text-align: right;"&gt;&lt;a class="button3" href="#" &gt;&lt;span&gt; Edit &lt;/span&gt;&lt;/a&gt; &lt;a class="button3" href="#" &gt;&lt;span&gt; Delete &lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr id="1" class="tr_group" style='display:none;'&gt;
                &lt;td style="width:10px;" class="dragHandle"&gt;&amp;nbsp;&lt;/td&gt;
                &lt;td&gt;&lt;a href=# style="margin-left: 20px;"&gt;Umair Iqbal&lt;/a&gt;&lt;/td&gt;
                &lt;td&gt;&lt;span style="font-size: 12px; color: #999; line-height: 100%;"&gt;A Student at TUM&lt;/span&gt;&lt;/td&gt;
                &lt;td style="text-align: right;"&gt;&lt;a class="button3" href="#" &gt;&lt;span&gt; Edit &lt;/span&gt;&lt;/a&gt; &lt;a class="button3" href="#" &gt;&lt;span&gt; Delete &lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr id="2" class="tr_group" style='display:none;'&gt;
                &lt;td style="width:10px;" class="dragHandle"&gt;&amp;nbsp;&lt;/td&gt;
                &lt;td&gt;&lt;a href=# style="margin-left: 20px;"&gt;Faryal Khan&lt;/a&gt;&lt;/td&gt;
                &lt;td&gt;&lt;span style="font-size: 12px; color: #999; line-height: 100%;"&gt;A Doctor at KMC&lt;/span&gt;&lt;/td&gt;
                &lt;td style="text-align: right;"&gt;&lt;a class="button3" href="#" &gt;&lt;span&gt; Edit &lt;/span&gt;&lt;/a&gt; &lt;a class="button3" href="#" &gt;&lt;span&gt; Delete &lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
            &lt;/tr&gt; 
&lt;/table&gt;
</code></pre>

<p>My Script is as follows</p>

<pre><code> &lt;script type="text/javascript"&gt;
        $(document).ready(function() {
            // $('#sort tr:even').addClass('alt');
            $('#sort').tableDnD({
                onDrop: function(table, row) {
                  alert(row.id);
                },
                dragHandle: ".dragHandle"
            });
            $("#sort tr").hover(function() {
                if($('#tr').hasClass('tr_group')) 
                {
                    $(this.cells[0]).addClass('showDragHandle');
                    }, function() {
                    $(this.cells[0]).removeClass('showDragHandle');
                }
            });
        });
 &lt;/script&gt;
</code></pre>

<p>It is not adding the class showDragHandle to the rows which has class "tr_group" on hover effect </p>

<p>What I am doing wrong any suggestions ?</p>

<p>Thanks in advance</p>
