js排他功能示例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="button" value="没怀孕">
<input type="button" value="没怀孕">
<input type="button" value="没怀孕">
<input type="button" value="没怀孕">
<input type="button" value="没怀孕">
<input type="button" value="没怀孕">
<script>
var btnObjs=document.getElementsByTagName("input");
for (var i=0;i<btnObjs.length;i++) {
btnObjs[i].onclick=function () {
for(var j=0;j<btnObjs.length;j++){
btnObjs[j].value="没怀孕";
}
this.value="怀孕了";
};
}
</script>
</body>
</html>
卡卡,你好吗