Here's what I am trying to do - I want to print out the text value of
a particular td. The easy solution would be to give each td in each
row a unique id (change code below so the first td to
id="row1_col1"). However if there is a way to access the text in col1
of row1 with jquery without giving each td element a unique id I'd
love to know. You can look at the code below to get the idea of what
I am trying to do.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<table cellspacing="5" cellpadding="5" border="1">
<tr id="row1">
<td id="col1">1</td>
<td id="col2">2</td>
</tr>
<tr id="row2">
<td id="col1">3</td>
<td id="col2">4</td>
</tr>
</table><br />
<script type="text/javascript">
str01 = $("#row1 > col1").text();// this doesn't work
document.write("row1 col1 value is: " + str01 + "<br />");
str02 = $("#row1").("col1").text();// this doesn't work
either, these are just for the attempts that failed
document.write("row1 col1 value is: " + str02 + "<br />");
</script>
</body>
</html>