[Solved] How to get row data of a html table in jquery?


It would be easier to answer if you had posted your html, but I’m guessing it looks something like this:

<table id="tblTest">
...
<td> <!-- this is the third td in #tblTest (#tblTest td:nth-child(3)) -->
    <a ...>Edit</a>
    <a ...>Delete</a>
</td>
</table>

Your jQuery selector is looking for all -tags in the third element. The function then calls event.preventDefault(). The problem is that you match both buttons when all you want is to match the edit button. An easy solution would be to add a class to the edit button and then add that class to the selector, so the function is only triggered for the edit button. This is how i would solve it:

<table id="tblTest">
...
<td>
    <a ... class="edit_button">Edit</a> <!-- add class to edit button. -->
    <a ...>Delete</a>
</td>
</table>

// will now only trigger for the edit button.
$("#tblTest td:nth-child(3) a.edit_button").click(function (event) { 
    ...
}

solved How to get row data of a html table in jquery?