Мой сценарий выглядит так: Я пытаюсь выбрать класс из списка классов, который начинается с числа, но имеет строку типа (я проверил).D3 дает мне синтаксическую ошибку с d3.selectAll()
list_item.on("click", function(){
var to_find = $(this).text().replace(/\s/g, "_");
console.log(typeof(to_find)); // on a certain moment this will become "00s"
sampleSVG.selectAll(".node:not(."+to_find+") circle, .line:not(."+to_find+")")
.transition()
.duration(500)
.style("fill", st_colours.node.fill)
.style("stroke", function(d){return d.type == "node" ? st_colours.node.stroke : st_colours.line.stroke});
sampleSVG.selectAll(".node."+to_find+" circle, .line."+to_find)
.transition()
.duration(1000)
.style("fill", st_colours.random(a))
.style("stroke", d3.rgb(st_colours.random(a)).darker());
});
Когда «вар to_find» переходит в «00s», я получаю эту ошибку:
SyntaxError: An invalid or illegal string was specified
Может кто-нибудь сказать мне, почему я получаю эту ошибку?