js排他功能示例
阿新 • • 發佈:2019-01-20
inpu this tro put ctype .get tel value btn
<!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>
js排他功能示例