我只是看着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.

Jquery相关问答推荐

通过 Ajax POST 将按钮值从 HTML 发送到 Flask 时出现空数据

我在自定义 WordPress 插件中使用 ajax 时收到错误请求

:eq Jquery,我似乎无法显示第一个之后的元素

使用 jQuery $.ajax() 时如何使用 GET 在请求正文中发送数据

提醒未保存的表单更改

JavaScript 或 jQuery 字符串以实用函数结尾

使用 jQuery 更改 CSS 类属性

如何在循环内创建动态变量名称?

如何设置缓存:jQuery.get 调用中的 false

jQuery.parseJSON 与 JSON.parse

如何在 JQuery UI 自动完成中使用 source:function()... 和 AJAX

如何在 JQuery DataTable 中默认显示所有行

使用 JQuery / JavaScript 调用/单击 mailto 链接

offsetTop 与 jQuery.offset().top

jQuery从字符串中删除'-'字符

在 bootstrap 弹出窗口中包含表单?

如何使用 jQuery 检测 IE 8?

Uncaught TypeError: undefined is not a function on loading jquery-min.js

带有 LIKE 的 Spring JPA @Query

jquery ui Dialog:无法在初始化之前调用对话框上的方法