我已經嘗試了這麼多的代碼。我有兩個帶有鏈接的圓圈,我需要爲相應鏈接的onclick圈起顏色。提出了一些解決方案如何用html5點擊相應鏈接時用顏色填充圓圈
<body>
<div class="row-fluid">
<div class="span1 offset3">
<canvas id="myCanvas" width="100" height="100"></canvas>
</div>
<div class="span1">
<br/><a href="#" onclick="function();">Hello</a>
</div>
<div class="span1">
<canvas id="myCanvas1" width="100" height="100"></canvas>
</div>
<div class="span1">
<br/><a href="#" onclick="function();">Hi</a>
</div>
</div>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(55, 30, 20, 0, 2 * Math.PI);
ctx.stroke();
var c = document.getElementById("myCanvas1");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(55, 30, 20, 0, 2 * Math.PI);
ctx.stroke();
function() {
//onclick function which will change the color of the correspondind circle
}
</script>
</body>
這不起作用! – Rohini