1

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?

var allTableCells = document.getElementsByTagName("td");
for(var i = 0, max = allTableCells.length; i < max; i++) {
    var node = allTableCells[i];

    //get the text from the first child node - which should be a text node
    var currentText = node.childNodes[0].nodeValue; 

    //check for 'one' and assign this table cell's background color accordingly 
    if (currentText.includes("$ -"))
        node.style.color = "red";
}

1 Answer 1

3
%%javascript
var allTableCells = document.getElementsByTagName("td");
for(var i = 0, max = allTableCells.length; i < max; i++) {
    var node = allTableCells[i];

    //get the text from the first child node - which should be a text node
    var currentText = node.childNodes[0].nodeValue; 

    //check for 'one' and assign this table cell's background color accordingly 
    if (currentText.includes("$ -"))
        node.style.color = "red";
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! It works as I put it on the last cell. Is it possible that jupyter will load this script every time I run a cell?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.