如何更改window.changeColour
通话分区ID而非窗口中的窗口?感谢
window.changeColour = function(value) {
switch(value) {
case 'b':
color = "#FF0000";
break;
case 'r':
color = "#0000FF";
break;
case 'p':
color = "#FF00FF";
break;
}
document.body.style.backgroundColor = color;
}
以下是HTML:
<div id= "genre">
<br><br>
<p>
<input type="radio" name="music" value="radio" onClick="changeColour('b')">Blues
<br>
<input type="radio" name="music" value="radio" onClick="changeColour('r')">Rock
<br>
<input type="radio" name="music" value="radio" onClick="changeColour('p')">Pop
<br>
</p>
</div>
答案 0 :(得分:0)
如果你的意思是获得身份Division
的元素,并改变它的颜色,这就是你得到的
var div = document.getElementById("Division")
div.changeColour = function(value)
{
switch(value)
{
case 'b':
color = "#FF0000";
break;
case 'r':
color = "#0000FF";
break;
case 'p':
color = "#FF00FF";
break;
}
div.style.backgroundColor = color;
}