Sangil's blog

https://github.com/ChoiSangIl Admin

JQUERY input type radio 체크된 값 가져오기 DEV / WEB

2018-12-05 posted by sang12


input type radio 체크된 값 가져오기. 쓸때마다 까먹음...

var inputValue = $("input[name='testInput']:checked").val(); 

EX)

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
      <script src="http://code.jquery.com/jquery-latest.min.js"></script>
      <title>test</title>
  </head>
  <body>
      <input type="radio" name="testInput" value="test1" checked="checked";/>
      <input type="radio" name="testInput" value="test2"/>
   </body>
</html>

<script type="text/javascript">
$(document).ready(function() {
     var inputValue = $("input[name='testInput']:checked").val();
     alert(inputValue);
});
</script>

var inputValue = $("input[name='testInput']:checked").val(); 

#input type radio checked value #input radio check #input 체크된값 가져오기
REPLY