I've been working with classes in a manner that I believe only works with the prototype.js (or prototype.lite.js) scripts, so a solution for this problem may be difficult or impossible to apply elsewhere. With that warning, here it is:
I'm looking for a way to list all class-based elements in the same way that one could list elements of a certian class (document.getElementsByClassName("aClass") ). Take, for example, this script:
window.onload = function() { a = new fighter(100,"Bob"); b = new fighter(200,"John"); c = new fighter(300, "Billy"); } var a, b, c; </script>
Note: this script was written entirely in-post, so I cannot test it and appologize if there are any scripting errors. The <html><body> etc. tags are not present for simplicity. What I'm looking for is a way to list a, b, and c without having to place them into an array when I initialize them - in other words, by calling functions like this: alert( document.getElementsByType("fighter").length ); I can't seem to find anything online that illustrates this capabilitiy in javascript. Is this even possible? Thanks ahead of time :)