Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YUI 3 Selector for multiple class names

I have a bunch of divs like this:

<div class="bear"></div>
<div class="dog"></div>

How do I get a nodelist that includes all divs with class of bear and dog? I tried:

Y.get(".bear .dog").each(function() {

});

But it returns null. Anyone have any suggestions? Thanks!

like image 397
atp Avatar asked Dec 04 '22 14:12

atp


2 Answers

Based on how CSS selectors work, it should be .bear, .dog

like image 186
VoteyDisciple Avatar answered Dec 27 '22 02:12

VoteyDisciple


Along with VoteyDisciple's answer, you should change the get to all.

For example:

YUI().use('node',function(Y) {
   console.log(Y.get(".bear, .dog").size());  // prints out 1
   console.log(Y.all(".bear, .dog").size());  // prints out 2
});
like image 23
seth Avatar answered Dec 27 '22 03:12

seth