:输入选择器返回按钮,但 :not([类型=按钮]) 不起作用



我正在组合选择器,以便仅选择html中的特定输入:

$('.content_container :input[type=radio]:checked, .content_container :input:not([type=radio])')

问题是它还返回<button type='button'>

我尝试添加以下内容:

.content_container :input:not([type=button])
.content_container :button:not([type=button])

到我的选择器,但它仍然返回按钮。我该如何安排?

您需要将

这两种类型组合在一个:not()中。

.content_container :input:not([type=radio],[type=button])

否则,带有 :not([type=radio]) 的选择器返回所有其他类型的输入,包括按钮,而带有 :not([type=button]) 的选择器返回所有其他输入,包括无线电,因此当您组合它们时,您将获得无线电和按钮,而不是同时排除两者。

最新更新