最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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");
发布评论

评论列表(0)

  1. 暂无评论