I want to offer code examples and I am using a JS code highlighter with an ID. See this URL for the working demo: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_syntax_highlight
I want to use this for multiple examples but the ID only works once. I have tried both ID and Class but this still doesn’t work.
w3CodeColor(document.getElementById("myDiv")); // only works for 1 element
w3CodeColor(document.getElementByClassName("myDiv")); // does not work
The example code what I have tried is below,
<div class="myDiv">code example goes here</div>
<div id="myDiv">code example goes here</div>
Any help would be much appreciated, thanks