I have a HTML table like this,
<table>
<tr class="AltTR">
<td>
First TD
</td>
<td>
Second TD
</td>
<td>
Third TD
</td>
<td>
Fourth TD
</td>
</tr>
</table>
When i click a table row, i want to do one operation, example need to show the alert window…
my jquery code is given below,
$(function(){
$(".AltTR").click(function() {
//if ($(this).find("td:first").is(":click"))
if ($(this).find("td:first").trigger('click'))
alert("1st TD is clicked");
else
alert("Other than 1st TD is clicked");
});
});
How to achieve this?
i have another doubt, “There is one link tag is in first TD, when we click that link, dont display any alert messages.. otherwise we want to display alert message whether it’s first TD or any other TD
You may try the index methord to your
tdsince its thetdwhere a user is clicking. Also you must wrap your code inside$(document).ready( function()like;Here is a working Live Demo.
And here is the updated fiddle as per your requirement.