I saw an example here and checked how it works but i got an error – (See Title)
Do you know why?
This is the code (Its similar to the link):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
Created using /
Source can be edited via /eyeyu/edit
-->
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<title>Sandbox</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
body { background-color: #000; font: 16px Helvetica, Arial; color: #fff; }
</style>
</head>
<body>
<table border="1">
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>4</td><td>5</td><td>6</td></tr>
<tr><td>7</td><td>8</td><td>9</td></tr>
<tbody>
</table>
<script>
$('td').click(function(){
var colIndex = $(this).parent().children().index($(this));
var rowIndex = $(this).parent().parent().children().index($(this).parent());
alert('Row: ' + rowIndex + ', Column: ' + colIndex);
});
</script>
</body>
</html>
Your code works just fine!
The problem by all the tests performed may come by the absence of the jQuery library,
see the live simulation link and print-screen.
Also, this working Fiddle Example!
As a side note:
tbodyand have the opening tagout of order:
UPDATE YOUR HTML TO THIS
UPDATE YOUR TAG TO THIS
AND
EDITED :: To better consolidate this answer
Note:
As stated by cliffs of insanity on the comments, .ready() is not needed on this case since the jQuery code is located below the elements it selects!