Looking to create 4 interactive buttons with a unique behavior. When clicked, the chosen button will change its background image while the other 3 buttons retain their original background image unless hovered over by the user. Additionally, hovering over any of the buttons should also trigger a change in the background image.
The challenge lies in finding the simplest way to achieve this effect without complex coding. Attempted a solution using :hover in CSS, but encountered issues with missing hover effects.
$s_btn_1.on('click',function() {
if (chosen!=1){
chosen = 1;
console.log('chosen');
$.get("services_1.php", function(data){
// $service_box.html(data);
});
return_default();
$folder1.css('background',"url('images/services/btn1_hover.png')");
$folder1.css('background-size',"100% 100%");
}
});
$s_btn_2.on('click',function() {
if (chosen!=2){
chosen = 2;
console.log('chosen');
$.get("services_2.php", function(data){
// $service_box.html(data);
});
return_default();
$folder2.css('background',"url('images/services/btn2_hover.png')");
$folder2.css('background-size',"100% 100%");
}
});
$s_btn_3.on('click',function() {
if (chosen!=3){
chosen = 3;
return_default();
$folder3.css('background',"url('images/services/btn3_hover.png')");
$folder3.css('background-size',"100% 100%");
}
});
$s_btn_4.on('click',function() {
if (chosen!=4){
chosen = 4;
return_default();
$folder4.css('background',"url('images/services/btn4_hover.png')");
$folder4.css('background-size',"100% 100%");
}
});
//$("#service_btn").addClass(".folder1_hover");
function return_default(){
$folder1.css('background-image',"url('images/services/btn1.png')");
$folder2.css('background-image',"url('images/services/btn2.png')");
$folder3.css('background-image',"url('images/services/btn3.png')");
$folder4.css('background-image',"url('images/services/btn4.png')");
$folder1.css('background-size',"100% 100%");
$folder2.css('background-size',"100% 100%");
$folder3.css('background-size',"100% 100%");
$folder4.css('background-size',"100% 100%");
}
});