19.03.2019, 06:40
You've added not appropriate word "and" in condition where in JS you have to use "&&" and there was no ")" at the end of $(function(){});
1. Simple class name withot any other signs.
2. Yes.
3. Every function is in another jQuery wrapper. You can add some comments/title like:
// 1. Coloring value by object________________________________________________
*Use console in browser, and when something strange happen, please console.log(someStrangeVariable)
This is full version in jQuery wrapper:
1. Simple class name withot any other signs.
2. Yes.
3. Every function is in another jQuery wrapper. You can add some comments/title like:
// 1. Coloring value by object________________________________________________
*Use console in browser, and when something strange happen, please console.log(someStrangeVariable)
This is full version in jQuery wrapper:
Code:
$(function(){
const colorByValue = (obj, type) => {
const {value} = obj;
const className = "color-by-value";
const element = document.querySelector(`.${className}`);
if (!element) return console.log(`You must add custom class "${className}" to some element.`);
if (value >= 0 && value <= 6) element.style.color = "red";
else if (value > 6) element.style.color = "green";
else if (value < 0) element.style.color = "blue";
};
grp.listen("1/1/0", colorByValue);
});
Done is better than perfect