シンプルなフォームを持ち、背景色を変更してフォーカスラベルを強調したいのですが、ここでjqueryが機能しないようです。 コンソールにエラーは表示されません。誰かが私にこれを助けてくれますか?ラベルフォーカスはCSSスタイルを変更しません
<form action="" method="POST" id="qrForm">
<label for="enter1">Enter<input id='enter1' type="radio" name="enter"></label>
<label for="enter2">Exit<input id='enter2' type="radio" name="enter"></label><br>
<label for="device1">Took a device<input id="device1" type="radio" name="device"></label>
<label for="device2">Returned a device<input id="device2" type="radio" name="device"></label>
</form>
<script>
$("label").focus(function(){
$(this).css('background-color', '#00CC66');
});
</script>
私は実際にクラスを追加/削除することでそれを終えることができましたが、なぜこれが機能していないのでしょうか?
label:focus {background-color:#111;}純粋なCSS –