【Selectors】jQueryを使った、Form処理APIのまとめ&メモ|HTMLアークアップ

:checked
チェックの入っているボックスの数を取得。
※必須項目が選択されているか確認するときなど

function countChecked() {
var n = $("input:checked").length;
$("div").text(n + (n == 1 ? " is" : " are") + " checked!");
}
countChecked();
$(":checkbox").click(countChecked);

引用元URL:http://semooh.jp/jquery/api/selectors/%3Achecked/

    • -

$("#test_result :checkbox").click(function(){
$("#display").text(
"チェックされている数は"+$("#test_result :checkbox:checked").length+"個だよ"
);
});

引用元URL:http://stacktrace.jp/jquery/api/selectors/checked.html

:selected
選択状態にある全ての要素を選択。

$("#test_result select").change(function(){
var str = "";
$("#test_result option:selected").each(function() {
str += $(this).text() + " ";
});

$("#display").text(str);
});
引用元URL:http://stacktrace.jp/jquery/api/selectors/selected.html

:radio
type属性がradio要素を選択。

$("#test_result :radio").parent().append($("").text("<-- radio").css("background", "yellow"));

引用元URL:http://stacktrace.jp/jquery/api/selectors/radio.html

:text
全てのtext要素を選択。

:contains(text)
指定された文字列を含む要素を返す。
※テキストエリアから禁止キーワードを探すときなど

[attribute]
マッチした要素のうち、指定された属性名を返します。
のname属性で探すときなど
 [属性名=文字列]
 [attribute=value]
 指定された文字列に”等しい要素”を返す。
 [attribute!=value]
 指定された文字列と”異なる要素”を返す。
 [attribute^=value]
 指定された文字列で”始まる要素”を返す。
 [attribute$=value]
 指定された文字列で”終わる要素”をす。
 [attribute*=value]
 指定された文字列を”含む要素”を返す。


(この記事はマークアップ勉強用メモです)