I run html5 web page with JS and jQuery where I receive forex quotes in real-time into my web page from my web service. I want to change TD background in green if price rise and red if price fall. Any good suggestions?
When you set the price in the td, save it also as a data-attribute. Now you can compare the previous value with the new value. Based on the evaluation (comparing old with new) set a class on the td that makes the background green or red.
Note: values stored as data-attribute are in String format. You will have to cast it to a Number manually (use parseInt())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.