score:2

Accepted answer

ids can't start with numbers. So the id itself is invalid. You can change the id in the HTML to something like _643, then in your JavaScript do

var top = d3.select("path#_643").style("fill", "green");

Here's an example using CSS to show id validity

#643 {
	background-color: orange;
	color: #FFF;
}
#_643 {
	background-color: orange;
	color: #FFF;
}
#-643 {
	background-color: orange;
	color: #FFF;
}
#six43 {
	background-color: orange;
	color: #FFF;
}
<ul>
	<li id="643">643</li>
	<li id="_643">_643</li>
	<li id="-643">-643</li>
	<li id="six43">six43</li>
</ul>


Related Query