Unfortunately, I am unable to find a straightforward solution. My goal is to adjust the text color inside my cell based on its value.
Here is a basic table:
<table>
<tbody>
<tr>
<td>Quantity</td>
<td>1</td>
</tr>
</tbody>
</table>
My criteria for formatting are as follows:
- If the number is 1, it should display in yellow
- If the number is greater than 1, it should display in red
I came across this code, but unfortunately, I'm unable to integrate it into my file at the moment. Thank you for your understanding.
$('#mytable tr td').each(function(){
if($(this).text() > 1)$(this).css('background-color','red');
});
Is there any alternative suggestion for addressing this issue?
Furthermore, what if my table includes other numeric cells like this one:
<table>
<tbody>
<tr>
<td>Price</td>
<td>20</td>
</tr>
<tr>
<td>Quantity</td>
<td>2</td>
</tr>
</tbody>
</table>
Is it possible to apply the code selectively only to certain cells?
I need to implement these modifications by editing the Prestashop MailAlert module that sends order confirmation emails.
In mailorder.php, I will need to incorporate the condition for changing the color of the quantity cell.
The email will be generated using the new_order.html file, which serves as the email template and fetches data from mailorder.php.
Where should I insert the script code? I can provide excerpts from the relevant files if necessary. Thank you.