53
rated 0 times
[
57]
[
4]
/ answers: 1 / hits: 113695
/ 9 Years ago, fri, october 16, 2015, 12:00:00
I have the following function which when triggered will make a DIV become semi-transparent.
function changeOpacity(el) {
var elem = document.getElementById(el);
elem.style.transition = opacity 0.5s linear 0s;
elem.style.opacity = 0.5;
}
However I would like this function to apply to several DIVs simultaneously. I tried giving each DIV the same class name and then using getElementsByClassName
but couldn't figure out how to implement it.
Would querySelectorAll
be more appropriate and if so how would I implement it?
More From » html