我需要从 html 调用一个 javascript 函数,但它似乎不起作用。我点击图像,没有任何反应。变量“brushVar”似乎没有改变。blue.png 是一个蓝色的小按钮,而 blueN.png 是一个蓝色的小按钮,具有不同的蓝色阴影,等等......非常感谢任何帮助
<body>
<script>
var brushVar;
function blue() {
brushVar = ("#000000");
alert(brushVar);
}
function blueN() {
brushVar = ("#000000");
alert(brushVar);
}
function cyan() {
brushVar = ("#000000");
alert(brushVar);
}
function cyanN() {
brushVar = ("#000000");
alert(brushVar);
}
function green() {
brushVar = ("#000000");
alert(brushVar);
}
function greenN() {
brushVar = ("#000000");
alert(brushVar);
}
function purple() {
brushVar = ("#000000");
alert(brushVar);
}
function purpleN() {
brushVar = ("#000000");
alert(brushVar);
}
function red() {
brushVar = ("000000");
alert(brushVar);
}
function redN() {
brushVar = ("000000");
alert(brushVar);
}
function yellow() {
brushVar = ("#000000");
alert(brushVar);
}
function yellowN() {
brushVar = ("#000000");
alert(brushVar);
}
</script>
<div id="buttons" style="position:absolute; width:100%; height:100%>
<a href="#" onclick="blue()';" >
<img src="/blue.png"/>
</a>
<a href="#" onclick="blueN()';" >
<img src="blueN.png"/>
</a>
<a href="#" onclick="cyan()';" >
<img src="cyan.png"/>
</a>
<a href="#" onclick="cyanN()';" >
<img src="cyanN.png"/>
</a>
<a href="#" onclick="green()';" >
<img src="green.png"/>
</a><a href="#" onclick="greenN()';" >
<img src="greenN.png"/>
</a>
<a href="#" onclick="purple()';" >
<img src="purple.png"/>
</a>
<a href="#" onclick="purpleN()';" >
<img src="purpleN.png"/>
</a>
<a href="#" onclick="red()';" >
<img src="red.png"/>
</a>
<a href="#" onclick="redN()';" >
<img src="redN.png"/>
</a>
<a href="#" onclick="yellow()';" >
<img src="yellow.png"/>
</a>
<a href="#" onclick="yellowN()';" >
<img src="yellowN.png"/>
</a>
</div>
</body>