在同一个表中,如何判断radio按钮和checkbox按钮处于同一行。

来源:百度知道 编辑:UC知道 时间:2024/05/12 23:54:41

把邮箱给我,我发给你。

<html>
<head>
<meta http-equiv=content-type content="text/html;charset=GBK">
</head>
<body>
<input type="radio" id="rao">
<input type="checkbox" id="chk">
<input type="button" value="测试" onclick="func()">
</body>
<script>
function func(){
var rad = document.getElementById("rao");
var chk = document.getElementById("chk");

// 判断两个元素的Y轴坐标, 相同则说明在同一行
if(rad.offsetTop == chk.offsetTop)
alert("它们在同一行");
else
alert("很抱歉我们不再同一行");
}
</script>
</html>
这样吧

同一组radio或者checkbox,名字相同即可,但是radio和checkbox是不是同一行不知