[jQuery] print out td in tr without unique ids
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. http://www.w3.org/TR/html4/loose.dtd";> http://code.jquery.com/jquery-latest.js";> 1 2 3 4 str01 = $("#row1 > col1").text();// this doesn't work document.write("row1 col1 value is: " + str01 + "
"); str02 = $("#row1").("col1").text();// this doesn't work either, these are just for the attempts that failed document.write("row1 col1 value is: " + str02 + "
");
[jQuery] accessing child element without unique id
I'm trying to access a td text value, as shown in the javascript below. The easiet way to solve this problem would be to give each td id value a unique identifier (i.e. td id="row1_col1") Is it possible to access the td element of a tr with a unique tr id tag without naming each td id uniquely? I'm new to this, I pasted the code as an example of what I'm trying to do. All the attempts in the javascript below failed. http://code.jquery.com/jquery-latest.js";> 1 2 3 4 str01 = $("#row1 > col1").text(); document.write("row1 col1 value is: " + str01 + "
"); str02 = $("#row1.col1").text(); document.write("row1 col1 value is: " + str02 + "
"); //str03 = $("#row1").("#col1").text(); //document.write("row1 col1 value is: " + str03 + "
"); //str04 = $("#col1").text(("#row1").text()); //document.write("row1 col1 value is: " + str04 + "
");