Jquery $(this) selector
<p>I am learning jQuery and I have this code : </p>

<pre><code> echo "&lt;table border=1&gt;                 
    &lt;tr&gt;&lt;th class='col1'&gt;Mã Sinh Viên &lt;a href='javascript:void(0)' data-page='$page' data-field='stuId' data-sort='$sort' data-key='$key'&gt;&lt;img src='downArrow.gif'&gt;&lt;/a&gt;&lt;/th&gt;
        &lt;th class='col2'&gt;Họ tên &lt;a href='javascript:void(0)' data-page='$page' data-field='stuName' data-sort='$sort' data-key='$key'&gt;&lt;img src='downArrow.gif'&gt;&lt;/a&gt;&lt;/th&gt;
        &lt;th class='col3'&gt;Ngày sinh  &lt;a href='javascript:void(0)' data-page='$page' data-field='stuDoB' data-sort='$sort' data-key='$key'&gt;&lt;img src='downArrow.gif'&gt;&lt;/a&gt;&lt;/th&gt;
        &lt;th class='col4'&gt;Giới tính &lt;a href='javascript:void(0)' data-page='$page' data-field='stuSex' data-sort='$sort' data-key='$key'&gt;&lt;img src='downArrow.gif'&gt;&lt;/a&gt;&lt;/th&gt;
        &lt;th class='col5'&gt;Địa chỉ &lt;a href='javascript:void(0)' data-page='$page' data-field='stuAdd' data-sort='$sort' data-key='$key'&gt;&lt;img src='downArrow.gif'&gt;&lt;/a&gt;&lt;/th&gt;
    &lt;/tr&gt;
";
</code></pre>

<p>And some script :</p>

<pre><code>$("#mainTable th a").click(function()   {
    var clicked= $(this);
    var page= clicked.data("page");
    var field= clicked.data("field");
    var sort= clicked.data("sort");
    var key= clicked.data("key");
    if(sort== 'up') {
        sort= 'down';
        clicked.html("&lt;img src='downArrow.gif'&gt;");
        clicked.attr("data-sort",sort);
    }
    else    { 
        sort= 'up';
        clicked.html("&lt;img src='upArrow.gif'&gt;");
    }
    showPage(page,field,sort,key);
});
</code></pre>

<p>What I need is when click on the image, it will change the picture. I used <code>.click</code> event and <code>$(this)</code> selector to handle element that was clicked. But when I click the picture it's still the same.</p>

<p>What's wrong with my code? I tried <kbd>CTRL-ALT-j</kbd> but there is no error. Please help me out.</p>
