これを凝縮する方法があるかどうか興味があります:
$("foo input:checkbox, foo input:radio");
私は以下を試しましたが、運はありません:
$("foo input[type="checkbox",type="radio"]");
これは盲目的に機能しません(構文が間違っています)
$("foo input[type="checkbox"][type="radio"]");
私はこれが両方のラジオであるすべての入力を選択すると思います そして チェックボックス。これは当てはまりません。
編集:
私が変更され fooElement
に foo
toiは例を単純化する
回答:
回答№1は4$("input[type="checkbox"], input[type="radio"]", $("fooelement"))
または
$("[type="checkbox"], [type="radio"]", $("fooelement input"))
または
$(":checkbox, :radio", $("fooelement input"))
jQueryには、検索するコンテキストを指定する機能があります。
回答№2については2
これを試して
$("fooElement input").filter(":checkbox, :radio");
回答№3の場合は1
$("fooElement").find(":checkbox,:radio");
回答№4の場合は0
$("fooElement input[type="checkbox"]").add("fooElement [type="radio"]");
回答№5の場合は0
それ自体は、実際には「凝縮」されていませんが、次のとおりです。
$("fooElement input[type="checkbox"], fooElement input[type="radio"]");