I'm currently having to extend an very old ASP.NET site which has a database generated front end and is a behemoth of an application, it needs completely rewriting - however I've been told to add to it than redevelop it - rats!
Okay the backend renders the following table on the front end:
<table id="tableID">
<tr>
<td class="qCol">
<!-- Label here -->
</td>
<td class="qCo2">
<!-- img here -->
<!-- and a text box -->
</td>
<td class="qCo3">
<!-- select menu here -->
</td>
<td class="qCo4">
<!-- radio buttons here -->
</td>
<td class="qCo5">
<!-- select menu here -->
</td>
<td class="qCo6">
<!-- hidden validation image here -->
</td>
<tr>
</table>
Now (Please don't ask why) I have to overwrite content of the td with the class "qCol" with the contents of the td with the class "qCo5".
This is a pretty easy affair using jQuery:
$('#tableID td.qCol').html($('#tableID td.aCo5').html());
Now I've amended the backend so more rows are generated for the table, none of these rows have an id and I need to do this HTML overwrite between the tds for each row (there will be 4 rows in total).
I know how to do this using JavaScript and a bit of looping but I want to get into the habit of using jQuery to do this, incorporating the .each() method.
I'm confused how I'd use "this
" and then select the appropriate td, for example...
$('#tableID tr').each(function () {
$(this).find('td .qCol').html($(this).find('td.aCo5').html());
});
What's the best way to do this?
If this question is poorly explained please say so and I'll expand