get radio button value jquery

get radio button value in jquery
index.html

<!DOCTYPE html>
<html>
<head>
    <title>How to get selected radio button value in Jquery? - pakainfo.com</title>
    <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
</head>
<body>
   
<input type="radio" name="sex" class="sex" value="male"> Male
<input type="radio" name="sex" class="sex" value="female"> Female
<button>Click to redirect</button>
   
<script type="text/javascript">
   
    $("button").click(function(){
        var selValueByClass = $(".sex:checked").val();
        console.log(selValueByClass);
    });
   
</script>
  
</body>
</html>

Free Live Chat for Any Issue
Rate this post