<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script type="text/javascript">
<!--
/**
* 如果选中“有”则,弹出提示框
* @param val 欲选中后弹窗的radio的值
*/
function showTip(val){
// 通过radio的名字取得radio控件数组集合
var radios = document.getElementsByName("sex3");
for (i=0,len=radios.length; i<len; i++) {
if (radios[i].checked) {
// 如果选中的radio的值为 val,则弹窗
if(val==radios[i].value){
alert('当前选中值:'+radios[i].value);
}
}
}
}
//-->
</script>
</head>
<body>
<div class="layui-input-block">
<input type="radio" name="sex3" value="1" title="有" onclick="showTip(1)"> 有
<input type="radio" name="sex3" value="0" title="无" checked> 无
<br /> <br /><br />
<input type="button" onclick="showTip(1)" value="选中 radio的 “有”选项时,弹出选中值,或者 点击 的radio的值为1时,才弹出提示。" />
</div>
</body>
</html>