Msg#: 3933971 posted 2:07 am on Jun 16, 2009 (gmt 0)
Hi, I have a widget that users can put on their own web-page. If the widget gets included multiple times, by a user, on his/her page then we will end up with a scenario with multiple widget-elements on the same page with the same id.
We have to be able to do some things with each of these widgets. Is there away that we can do a document.getElementbyId() and get an array of all matching elements?
For what we are doing we are running into a problem with Firefox.
Msg#: 3933971 posted 1:33 pm on Jun 16, 2009 (gmt 0)
Most browsers don't break if it isn't though, but I agree, it definitely should be.
The jQuery way:
// Get all elements with class 'myclass' var nodes = $('.myclass');
The YUI 2.7.0 Selector way:
// Get all elements with class 'myclass' var nodes = YAHOO.util.Selector.query('.myclass');
The YUI 2.7.0 getElementsByClass way:
// Get all elements with class 'myclass' var nodes = YAHOO.util.Dom.getElementsByClassName('myclass');