简体   繁体   中英

How to insert javascript code into Jupyter

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";
}
%%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";
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM