开发者

adjusting table content with javascript by enumerating rows

开发者 https://www.devze.com 2022-12-26 09:21 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消