如何将 javascript 代码插入 Jupyter
How to insert javascript code into Jupyter
我正在尝试在 custom.js 上插入此脚本。我把所有的负货币都改成红色。
我希望它应用于所有 pandas 在 Jupyter 上打印的数据帧。将其添加到 jupyter/anaconda 文件夹中所有可用的 custom.js 后,它仍然没有任何改变。有人可以帮助我吗?
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";
}
use the jupyter javascript magic
%%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";
}
我正在尝试在 custom.js 上插入此脚本。我把所有的负货币都改成红色。
我希望它应用于所有 pandas 在 Jupyter 上打印的数据帧。将其添加到 jupyter/anaconda 文件夹中所有可用的 custom.js 后,它仍然没有任何改变。有人可以帮助我吗?
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";
}
use the jupyter javascript magic
%%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";
}