Good night (good morning or good afternoon) to everyone!
I need a function that returns the value of a css property. Here is my code:
CSS:
.teste{
opacity: 0;
display: none;
}
JavaScript:
function funcao(){
var elemento = document.getElementById("teste");
function css(el, estilo){
alert(document.defaultView.getComputedStyle(el, null).estilo);
}
css(elemento, "display");
}
However this returns "Undefined", so I did the function with only 1 parameter, below: JavaScript:
function funcao(){
var elemento = document.getElementById("teste");
function css(el){
alert(document.defaultView.getComputedStyle(el, null).display);
}
css(elemento);
}
In this case, it returns "none". The problem is that I will need to fetch the value of several properties of several classes, so the css (el, style) function would be perfect (if it worked and returned the "none" in the example), so I could use, for example: br>
css(teste, display);
css(teste, visibility);
css(testeDois, display);
The css () function only has the "alert" for me to test what it returns, in the end, when it is working it will not have the "alert", it will only return the property value of the class
Thank you all, hopefully, I have managed to be clear in my problem
Many thanks!