【问题标题】:How to find an element using CSS2 Selector in Motoools and hide it?如何在 Mootools 中使用 CSS 选择器查找元素并将其隐藏?
【发布时间】:2011-01-05 01:21:01
【问题描述】:

如何通过 Mootools 的 Css 选择器在 #conttile2 中找到这个带有 class="rocon.rocon-br" 的 span 元素?这个元素是由 Javascript 动态创建的(圆角),所以这就是我在 Dragonfly Dom 树中看到的:

html > body > div#wrapper.wrapper > div#penalties.container > h2#conttitle2.rc10.rocon__8.rocon-init > span.rocon.rocon-br

树中有这个类的其他元素。

我试图得到它并像这样隐藏:

$$('h2#conttitle2>span.rocon.rocon-tl').each(function(corners) {corners.setStyle('display','none');});

一个偶数

$('conttitle2').getElements('span[class=rocon rocon-tl]').each(function(corners) {corners.setStyle('display','none');});

但它根本不会隐藏:( 您能否告知隐藏此元素的正确语法是什么?

【问题讨论】:

  • 发布您尝试定位的标记/生成的 html...

标签: javascript css css-selectors mootools


【解决方案1】:

试试这个选择器:

#conttile2 > span[class~="rocon.rocon-br"]

attribute selector [attr~=value] 用于空格分隔的列表,例如 class 属性的值。

【讨论】:

  • @moogeek:你的span元素是ID为conttile2的元素的子元素?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多