要素の背景とテキストの色が一致しているかどうかを確認したいのですが、check();
2回目のマウスクリックの後に呼び出されるという事実を除いて、すべて問題ありません!
function check() {
if(document.getElementById("cimg").style.backgroundColor == document.getElementById("cimg").style.color) {
alert("Matched");
}
}
function show() {
document.getElementById("cimg").style.backgroundColor = "blue";
}
私のDiv(実際には画像ボタン):
<div class="blue" id="bg1" onClick="check(); return show();" title="Blue"></div>
cimg は、div
変更を表示する場所の ID です。PS: jQuery/CSS/PHP の回答は大歓迎です!