replacement for document.all.sort.length
function ShowSortArrows() {
for ( var i = 0; i < document.all.sort.length; i++ ) {
document.all.sort[i].style.display = "none";
document.all.sort[i].style.visibility = "";
}
if (iSortByColumn!=1) {
if (strSortType=="ASC") {
document.all.sort[(iSortByColumn*2)-4].style.display="inline";
} else {
document.all开发者_StackOverflow中文版.sort[(iSortByColumn*2)-3].style.display="inline";
}
}
}
This is not supported in new browsers, so I need replacement.
Thanks,
IlijaBased on what you showed sort
can be 2 things.
- a
<form>
with the name or idsort
- a collection of form elements named
sort
The solutions for these situations are:
(1)
var sort = document.getElementById("sort");
var elements = sort.getElementsByTagName("input");
(2)
var input = document.getElementsByTagName("input");
var elements = [];
for (var i = 0; i < input.length; i++) {
if (input[i].name === "sort") {
elements.push(input[i]);
}
}
Then the elements
array will contain what you would get with the old-fashioned document.all.sort
It basically depends on what sort
is (no HTML shown). It's not a valid HTML tag and there appear to be more than one per page so I'll assume it's a class name :-?
for ( var i=0, len=document.getElementsByClassName("sort").length; i<len; i++) {
}
精彩评论