I'm trying to all the text in a div by class name:
<div class="something...">
And then replace the text with something. No, i don't want to use jquery.
Should be straight forward
var elements = document.querySelectorAll('.something'); for ( var i=elements.length; i--; ) { elements[i].textContent = "something else"; }
<div class="something">Soft</div> <br> <div class="something">Kitty</div> <br> <div class="something">Warm</div> <br> <div class="something">Kitty</div> <br> <span class="something" style="color:green">Little ball of fur ...</span>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.