Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Element By using Class name

I want Element by using class name

Now I am using GWT 2.0

Please help me

Thanks

like image 695
Tushar Ahirrao Avatar asked Aug 13 '10 16:08

Tushar Ahirrao


People also ask

How do you find an element with a specific class name?

Use the element. classList. contains() method to check if an element contains a specific class name.

Can we get element by class?

You may also call getElementsByClassName() on any element; it will return only elements which are descendants of the specified root element with the given class name(s).

How do you traverse through the elements selected by get elements by class name method?

getElementsByClassName method is to use the for-of loop. We call document. getElementsByClassName with 'slide' to return an HTML element collection object with all the divs. Then we use the for-of loop to loop through each item.


1 Answers

https://developer.mozilla.org/en/DOM/document.getElementsByClassName

e: not supported natively in IE < 9, so you'd have to extend document / make a global function with something like this: http://robertnyman.com/2008/05/27/the-ultimate-getelementsbyclassname-anno-2008/ or use something like sizzle or jquery - thanks to comments below.

like image 83
dmp Avatar answered Oct 01 '22 18:10

dmp