我们可以在mootools选择器中使用关系运算符吗?比方说,我有两个不同名称的复选框。如何在单选择器查询中获取它们。
答案 0 :(得分:4)
对于mootools选择器引擎Slick,它与jquery中的相同:
document.getElements("div.foo, div.bar, div.bar a");
或者也称为$$
。
$$("div.foo,div.bar"); // vs $("div.foo,div.bar"); in jquery
两个框架都试图遵守CSS 3 selectors并使用反向组合器等边缘情况进行扩展
注意mootools中的$是document.id
的别名,您可以将其视为document.getElementById
,与jquery函数包装器完全不同,它返回单个元素。如果你想通过id选择一个元素document.id("someid")
而不是$("#someid")
,或者是jquery用户进入$$("#someid")
的mootools时所引起的错误。但是,您可以使用$$("#someid,#anotherid")
通过其ID获取元素集合。
答案 1 :(得分:1)
在JQuery中,您可以输入多个选择器,除以逗号:
http://api.jquery.com/multiple-selector/
$("div,span,p.myClass").whatever ...