Just like in jQuery we can use $(“.classname”), is there a similar thing in javascript as well? Or if we don’t have such method then how can i implement that.
According to http://www.dustindiaz.com/getelementsbyclass/ i will have to iterate through all tags and then collect all elements which are having the same class as specified.
Is there any better solution?
Some browsers, for example Firefox 3 support getElementsByClassName, others you have to iterate though all the tags, so if you wanted to support all browsers with a single function you should use the iterative method.
The best solution is to use jQuery or any other framework which will use the best available method.