ボタンのように機能するimgを作成するために、htmlと非常に基本的なjQueryを組み合わせて使用しているため、imgをクリックすると、画像のsrc(src1)が別のsrc(src2、つまり画像)に変わります。ボタンが押されたの)。同じ画像(現在はsrc2)をクリックすると、元のsrc(src1)に戻るようにしようとしています。
それが理解するのに頭痛の種ではなかったことを願っています。必要に応じて明確にすることができます。
これが私がコードのために持っているものです:
<!--Html-->
<body>
<img id="pixelbutton" src="images/pixelbutton.png" onClick="pixelbuttonclick()" />
</body>
/* jQuery */
function pixelbuttonclick() {
var pixelbutton = document.getElementById("pixelbutton");
if (pixelbutton.style.src=="images/pixelbutton.png") {
document.getElementById("pixelbutton").src="images/pixelbutton_press.png";
}
else if (pixelbutton.style.src=="images/pixelbutton_press.png") {
document.getElementById("pixelbutton").src="images/pixelbutton.png";
}
}
私は巨大な初心者なので、可能であれば、それほど複雑でない答えをいただければ幸いです。