Both Andy and Simon have come up with very interesting, and potentially very useful, functions for JavaScript. Andy started it by creating document.getElementsByClassName
, a function that will return an element based on its class name. Then Simon come up with the idea of being able to select an element by using CSS selectors. Thus document.getElementsBySelector
was born. So far they both seem to work in modern browsers.
I personally think document.getElementsBySelector
will get more use because it is much more flexible. But that coming from a guy who, until a few months ago, loathed using JavaScript is not saying much. I actually enjoy using JavaScript now, but with one reservation: I will use it only to add features which can be safely lost in a browser with no JavaScript support. As cool as some JavaScript can be, it irks me to see some sites use it as a critical component to the function of their page.