online Editor
val() | Attributes - jQuery リファレンス
val() - 3 - jQueryのval()の:checkedセレクタを利用したサンプルです。
<!DOCTYPE HTML> <html lang="ja"> <head> <meta charset="UTF-8"> <title>sample1</title> </head> <body> <!--ラジオボタン--> <input type="radio" name="myRadio" value="radio01"> <input type="radio" name="myRadio" value="radio02" checked> <input type="radio" name="myRadio" value="radio03"> <!--チェックボックス--> <input type="checkbox" name="myCheckbox" value="checkbox01"> <input type="checkbox" name="myCheckbox" value="checkbox02"> <input type="checkbox" name="myCheckbox" value="checkbox03" checked> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> console.log( $('input[type=checkbox]:checked').val() ); console.log( $('input[type=radio]:checked').val() ); </script> </body> </html>
HTMLを反映する >>
タグ:
jQuery
val()
Web Creative Park