i need to find the position of a child element.
i have a table and when a td is clicked, i want the position of the td(0,1 or 2)
<table>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
and a script like this
<script>
$("td").click(function(){
//how do i get the position of the td?
alert("column " + columnPosition + "is clicked")
});
</script>
<script>
$("td").click(function(){
//how do i get the position of the td?
alert("column " + $(this).parent().children().index(this) + " is clicked")
});
</script>
edit: I tested it, and it works
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With