This is the output of one of my file
<table>
<tr>
<td> Description 1 </td> <td> Content 1 </td>
</tr>
<tr>
<td> Description 2 </td> <td> Content 2 </td>
</tr>
<tr>
<td> Description 3 </td> <td> Content 3 </td>
</tr>
I want to get the content of Description x with php and then I want to read out the Content x. One of my problem is, that before grapping the content I don't know how many description-td's I have.
Should DOM / getElementsBy ... work for my problem?
Best regards, Susan
Here you have a solution with JQUERY. Try if yourself In this example we show in an alert dialog the content of the description number 3.
HTML:
<table id="mytable">
<tr>
<td> Description 1 </td> <td> Content 1 </td>
</tr>
<tr>
<td> Description 2 </td> <td> Content 2 </td>
</tr>
<tr>
<td> Description 3 </td> <td> Content 3 </td>
</tr>
</table>
JQUERY:
// Search content of description number 3
$(document).ready(extractContent(3));
function extractContent(num) {
$('td', $('#mytable')).each(function() {
// The text in the first column must match " Description num "
if ($(this).text() == " Description " + num + " ")
alert("Content found: "+$(this).next().text());
});
}