我有以下 html -
<input type="Radio" name="radio2text" value="Radiobutton1"
onclick="javascript:radioWithText('one')" checked="checked" />OneRadio<br/>
<input type="Radio" name="radio2text" value="Radiobutton2"
onclick="javascript:radioWithText('two')" unchecked />TwoRadio
<br/>
<input type="Radio" name="radio2text" value="Radiobutton2"
onclick="javascript:radioWithText('three')" unchecked />ThreeRadio
<br/>
<input type="Radio" name="radio2text" value="Radiobutton2"
onclick="javascript:radioWithText('four')" unchecked />FourRadio
还有这个
<span id="one" name="one" width="5px" style="background-color:#fff;"> </span>
<span id="two" name="one" width="5px" style="background-color:#fff;"> </span>
<span id="three" name="one" width="5px" style="background-color:#fff;"> </span>
<span id="four" name="one" width="5px" style="background-color:#fff;"> </span>
这会在我的绿色背景颜色上产生一个 4 小宽度的白色正方形。Those four square are shown and i want to change their color off-course background to be red when particular radio button is selected. 对于那次摇晃,我用 javascript 传递了一个参数javascript:radioWithText('one')
。如您所见,该函数传递了一个参数 ok!接下来是用我调用的函数做javascript。
function radioWithText(d) {
alert(d);
if (d.val=='one')
{
var one = document.getElementById('one');
//one.checked = true;
one.style.background="red";
}
}
您可能会看到,当单选按钮被选中时,它会提醒传递的值(被选中的按钮)。在警报中它显示"one"
"two"
"three"
"four"
当放置第一个单选按钮时相同的值在"one"
比较时通过它不比较可能是什么原因?帮帮我!
拼命一个愚蠢的错误提前谢谢