I’m trying to insert this script on custom.js. I changes to color red all the negative currency.
I want it to be applied to all pandas dataframes printed on Jupyter. After adding it to all custom.js available on jupyter/anaconda folders, it still didn’t change anything. Can someone help me?
JavaScript
x
12
12
1
var allTableCells = document.getElementsByTagName("td");
2
for(var i = 0, max = allTableCells.length; i < max; i++) {
3
var node = allTableCells[i];
4
5
//get the text from the first child node - which should be a text node
6
var currentText = node.childNodes[0].nodeValue;
7
8
//check for 'one' and assign this table cell's background color accordingly
9
if (currentText.includes("$ -"))
10
node.style.color = "red";
11
}
12
Advertisement
Answer
JavaScript
1
13
13
1
%%javascript
2
var allTableCells = document.getElementsByTagName("td");
3
for(var i = 0, max = allTableCells.length; i < max; i++) {
4
var node = allTableCells[i];
5
6
//get the text from the first child node - which should be a text node
7
var currentText = node.childNodes[0].nodeValue;
8
9
//check for 'one' and assign this table cell's background color accordingly
10
if (currentText.includes("$ -"))
11
node.style.color = "red";
12
}
13