[英]Change script for radio buttons to regular buttons
因此,我一直在使用此腳本,該腳本可以很好地實現我的目的,但是它是用單選按鈕構建的,因此我被要求使用它進行另一個項目,但是我的老板希望按鈕現在可以正常使用,非單選按鈕。
這是到目前為止我一直在使用的代碼。 將單選按鈕代碼轉換為常規按鈕代碼比我想象的要難得多! 任何幫助將不勝感激,謝謝!
<!DOCTYPE html>
<html>
<head>
<style>
#TFholder{
background-image:url('truefalse.png');
height:84px;
width:576px;
}
button{
height:84px;
width:280px;
color:white;
background-color:black;
margin-top:50px;
text-align:center;
line-height:10px;
border:none;
outline:none;}
button a{
display:block;
color:white;
text-decoration:none;
padding:20px 40px;}
</style>
</head>
<body>
<script type="text/javascript">
function onCheck() {
if (document.getElementById('check1').checked) {
document.getElementById('truebox').style.display = 'block';
}
else document.getElementById('falsebox').style.display = 'block';
}
</script>
<input type="radio" onclick="javascript:onCheck();" name="check" id="check1"><br>
<input type="radio" onclick="javascript:onCheck();" name="check" id="check2"><br>
<div id="TFholder">
<div id="truebox" style="display:none">
<button type="button">CONTINUE!!!</a></div>
</div>
<div id="falsebox" style="display:none">
<button type="button">SECOND BUTTON!!!</a></div>
</div>
</div>
</body>
</html>
將HTML部分更改為:
<input id="Button1" type="button" value="button" onclick="javascript:b1();"/><br />
<br />
<input id="Button2" type="button" value="button" onclick="javascript:b2();"/><br>
將腳本部分更改為:
<script type="text/javascript">
function b1() {
document.getElementById('truebox').style.display = 'block';
}
function b2() {
document.getElementById('falsebox').style.display = 'block';
}
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.