我只是看着jQueryUI按钮插件,注意到了这一点
$("button, input:submit, a", ".demo").button();
I never seen something like this. Is this like multiple selects in one jQuery selector?
我只是看着jQueryUI按钮插件,注意到了这一点
$("button, input:submit, a", ".demo").button();
I never seen something like this. Is this like multiple selects in one jQuery selector?
第二个参数(在您的示例中为".demo"
)是context,基本上您的 Select 器仅限于匹配已确定的context的后代:
$(expr, context)
等同于使用find
方法:
$(context).find(expr)
请查看jQuery function人的文档:
Select 器上下文
默认情况下, Select 器执行
$('div.foo').click(function() {
$('span', this).addClass('bar');
// it will find span elements that are
// descendants of the clicked element (this)
});
Also notice that the selector you post "button, input:submit, a"
, is called Multiple Selector, and there you can specify any number of selectors to combine into a single result, just by separating them by a comma.