Disable click on table rows
I'm trying to disable the onclick event on a ASP.NET gridview that generates following HTML markup:
- <table id="GridViewPP" >
- <tr >
- <th scope="col">PP</th>
- </tr>
- <tr class="SelectedRow" onclick="javascript:__doPostBack('GridViewPP','Select$0')">
- <td align="center">N</td>
- </tr>
- </table>
I used the following code, but the mouse click would still postback, triggering the SelectedIndexChanged event on the server-side:
- $("table#GridViewPP tr").click(function(event) {
- alert("click");
- this.onclick = null;
- event.preventDefault();
- event.returnValue = false;
- return false;
- });
It seems the postback has occurred prior to the jQuery code kicked in. How can I prevent the postback? Thanks.
Quan