我有 2 种不同的 jquery 效果我想应用于表单单选按钮,一方面我有按钮的悬停效果,另一方面我有所选单选按钮的背景颜色更改。这是代码:
对于悬停:
$(".label_radio").hover(function () {
$(this).css("background-color", "silver");
},function () {
$(this).css("background-color", "transparent");
});
对于所选项目:
$("#uno").click(function () {
$("#cambiar").css("background-image", "url(../wp-content/uploads/blanco2patas.jpg)");
$("#BU").css("background", "red");
$("#BT").css("background", "transparent");
$("#NU").css("background", "transparent");
$("#NT").css("background", "transparent");
});
$("#dos").click(function () {
$("#cambiar").css("background-image", "url(../wp-content/uploads/blanco4patas.jpg)");
$("#BU").css("background", "transparent");
$("#BT").css("background", "red");
$("#NU").css("background", "transparent");
$("#NT").css("background", "transparent");
});
$("#tres").click(function () {
$("#cambiar").css("background-image", "url(../wp-content/uploads/negro2patas.jpg)");
$("#BU").css("background", "transparent");
$("#BT").css("background", "transparent");
$("#NU").css("background", "red");
$("#NT").css("background", "transparent");
});
$("#cuatro").click(function () {
$("#cambiar").css("background-image", "url(../wp-content/uploads/negro4patas.jpg)");
$("#BU").css("background", "transparent");
$("#BT").css("background", "transparent");
$("#NU").css("background", "transparent");
$("#NT").css("background", "red");
});
我的问题是,当我尝试应用悬停效果时,当我将鼠标悬停在所选元素上时,它会触发悬停效果,但是当我移除鼠标时,它不会显示所选效果。它应该保持红色,但我得到透明元素