I need to change the content of spans with a class name using JavaScript. I prefer JavaScript over jQuery because this is a basic site and isn't loading a jQuery file, and I'd rather not add on the file just for this one thing. Here is what I've tried:
HTML:
blah blah blah <span class="new"></span> blah blah blah
JavaScript in external JavaScript file:
document.getElementsByClassName('.new')[0].innerHTML = 'new text here';
Hoping it would show up as: blah blah blah new text here blah blah blah
Did a search but only found ElementID solutions.
tag make a difference? Or the [0] maybe? Note: All the other scripts on the js file work fine, so it's loading.
– midknyte Mar 29 '16 at 00:08