I just find that document.getElementsByClassName() is not available for IE8. For this reason I want use document.querySelectorAll(), but my real problem is that class name come in a varible, and can't get the result of the function. Like this:
var linea = document.querySelectorAll(revisados[i].value);
My function is triggered by an checkbox by an onchange(value), and when the execution check the parameter value of querySelectorAll fail. I tried:
<input type="checkbox" value="1" onchange="javascript:name(this)" />
The value is a class for many other elements. And the JS:
function name(param){
var className=param.value;
var class2 = "."+class;
var linea = document.querySelectorAll("."+param); //doesn't work
var linea = document.querySelectorAll("."+className); //doesn't work
var linea = document.querySelectorAll("."+className.value); //doesn'twork
var linea = document.querySelectorAll(class2); //doesn'twork
var linea = document.querySelectorAll(String(class)); //doesn't work
}
Please any suggestion. Thanks a lot.
onchageinstead ofonchange. Also, you can not useclassas a javascript variable name because it will produceUncaught SyntaxError: Unexpected reserved word.javascript:part in your inline event handler is completely unnecessary. I recommend to remove it to not spread the false impression that it is required.document.querySelectorAll("."+param);? What do you expect from concatenating a DOM Element with a string? Similar fordocument.querySelectorAll("."+className.value);. Strings don't have avalueproperty. I feel you would benefit from refreshing some JS basics. I mean, trying things out is good, but it seems like you blindly tried every possible combination. Maybe take a step back and read some documentation: developer.mozilla.org/en-US/docs/Web/API/Document/…