Try to select all elements by
document.querySelectorAll(".read-more");
I am updating the script https://jsfiddle.net/rzdkr2gL/7/
And you can use the forEach method
actualButtons.forEach(function (el) { el.parentNode.className = "basic"; el.className = "btn btn-xs btn-default"; })
or (recommended method)
Array.prototype.forEach.call(actualButtons, function (el) { el.parentNode.className = "basic"; el.className = "btn btn-xs btn-default"; })
or
NodeList.prototype.forEach.call(actualButtons, function (el) { el.parentNode.className = "basic"; el.className = "btn btn-xs btn-default"; })
The final code may look like https://jsfiddle.net/rzdkr2gL/8/
source share