html code
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="main.js"></script>
<title>Untitled Document</title>
</head>
<body>
<input type="radio" name="group1" value="1">
<input type="radio" name="group1" value="2">
<input type="radio" name="group1" value="3">
<input type="radio" name="group1" value="4">
<input type="radio" name="group1" value="5">
<input type="button" id="all">
</body>
</html>
// JavaScript Document
$(document).ready(function() {
//case 1 - work
$("input:radio[name=group1]").click(function(){
var email_num = $(this).val();
alert(email_num);
});
$("#all").click(function(){
// case 2 - now work, why? (wrong value)
var n = $("input:radio[name=group1]").val();
alert(n);
})
});