does Dom support selecting items by class name

1198
5
Jump to solution
02-01-2017 01:08 PM
EvonFranklin
New Contributor III
On(Dom.byId("class-name"),

This works for listening for ID changes, however is there a way to target DOM elements by class name?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
EvonFranklin
New Contributor III
On(document, On.selector(".imgs", Mouse.enter), function(){logger();});

Eventually used this, I had to import the "Mouse" and "Query" dojo kits as well.

View solution in original post

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus

Evon,

   You can use "dojo/query"

i.e. 

var nl = query(".someClass", "someId");
0 Kudos
EvonFranklin
New Contributor III

and this will be enabled for dynamically added elements with the same class name? (.someClass) is added to the DOM tree after a button is pressed. Then can I add a "hover" listener to this element?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Sure

0 Kudos
EvonFranklin
New Contributor III

I see, I want to ultimately achieve a mouseover effect when the mouse hovers over a certain img tag.

0 Kudos
EvonFranklin
New Contributor III
On(document, On.selector(".imgs", Mouse.enter), function(){logger();});

Eventually used this, I had to import the "Mouse" and "Query" dojo kits as well.

0 Kudos