最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Mootools - selecting a DOM element by its classes - Stack Overflow

matteradmin3PV0评论

I use MooTools, and I need to find the element which has both classes "a" and "b" (the innermost div in my example below).

The HTML structure is:

<div class="a">
   <div class="otherclass">
      <div class="b"></div>
   </div>
 </div>

In jQuery it's $("div .a .b"), as far as I know. What's the mootools syntax? I've tried

$$("div .a .b")

but it doesn't return any results.

Thanks!

-- To clear things, I want to get ONLY the divs which have both classes (in this case, only one.) thanks.

I use MooTools, and I need to find the element which has both classes "a" and "b" (the innermost div in my example below).

The HTML structure is:

<div class="a">
   <div class="otherclass">
      <div class="b"></div>
   </div>
 </div>

In jQuery it's $("div .a .b"), as far as I know. What's the mootools syntax? I've tried

$$("div .a .b")

but it doesn't return any results.

Thanks!

-- To clear things, I want to get ONLY the divs which have both classes (in this case, only one.) thanks.

Share Improve this question edited Jan 11, 2010 at 13:10 Nir asked Jan 11, 2010 at 11:35 NirNir 4,0138 gold badges39 silver badges53 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 1
var divsB = $$("div.a div.b");

http://mootools/shell/jfnWK/ - selects the first one but not the second as it's not a child of a div.a

What about

$$('div.a div.b')

or

$$("div.a").getElements("div.b");
Post a comment

comment list (0)

  1. No comments so far