I have a table row with 4 columns on my ecommerce site and I want to replace the content of 1st column if total amount in last column (TD class "total") is over 10 EUR.
How can I do this with javascript only, I guess somehow to enumerate through the table rows and look fo开发者_JAVA百科r a correct row (one with the last column class as total) and then access the content of 1st column on this row but how?
You could do easily with JQuery:
if (parseInt($('.total').text(), 10) > 10)
{
$('#your_table_id td:first').html('your content here');
}
Note: You could use text()
instead of html()
if you are interested in textual contents.
精彩评论