Accepted answer

Use a quoted string to delimit the value of your attribute:

var textElem ="text[id='']");

var el ="text[id='']");{fill: 'red'})
<script src=""></script>
     <text id="" x="10" xml:space="preserve" y="10" stroke="none">Text/<text>


Another solution would be to escape each period by putting a backslash \ before it—then you can use or d3.selectAll() as usual.

You can use .replace(/\./g, '\\.') to add the backslashes automatically.

Remember (thanks, altocumulus!), to escape the backslashes themselves with another backslash if you're editing the id manually."#element\\.id\\.with\\.dots")

Related Query

More Query from same tag