Thursday, September 4, 2014

Table td click event using jQuery

jQuery
$(document).ready(function () {

            $("#mytable td").click(function () {
                alert($(this).html());
                alert($(this).attr('class'));               
            });           

        });

HTML:
<table id="mytable" style="width: 100%;">

        <tr>
            <td class="s">Row11</td>
            <td>Row12</td>
            <td>Row13</td>
        </tr>
        <tr>
            <td>Row21</td>
            <td>Row22</td>
            <td>Row23</td>
        </tr>
        <tr>
            <td>Row31</td>
            <td>Row32</td>
            <td>Row33</td>
        </tr>
    </table>

No comments:

Post a Comment