Skip to content

Instantly share code, notes, and snippets.

@alanerzhao
Created June 12, 2014 02:52
Show Gist options
  • Save alanerzhao/9a476f3463628833d28c to your computer and use it in GitHub Desktop.
Save alanerzhao/9a476f3463628833d28c to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<label for="EMAIL"> <input type="radio" id="EMAIL" name="contact_type" value="1"><span>邮箱 </span></label>
<label for="QQ"> <input type="radio" id="QQ" name="contact_type" value="2"><span>QQ</span></label>
<label for="PHONE"> <input type="radio" id="PHONE" name="contact_type" value="3"><span>电话</span></label>
<label for="OTHER"> <input type="radio" id="OTHER" name="contact_type" value="4"><span>其它</span></label>
<button>ok</button>
<script src="./js/jquery.js"></script>
<script>
var radioOpt = $("input[name='contact_type']");
$("button").click(function () {
var power = false;
var text = '';
radioOpt.each(function (idx,obj) {
if($(obj).is(":checked")) {
power = true;
text = $(this).val();
return false;
} else {
power = false;
}
})
console.log(power,text)
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment