Created
March 18, 2023 15:05
-
-
Save FrancoStino/1b2de9147a5b07dee4e7d1d48f2b743a to your computer and use it in GitHub Desktop.
Change color of select variation after alert Jquery - Woocommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($){ | |
$('.single_add_to_cart_button, .wd-buy-now-btn').on("click change", function(e){ | |
if ($('.variations select').val() === "") { | |
// e.preventDefault(); | |
alert("Seleziona le opzioni del prodotto prima di aggiungerlo al carrello."); | |
$('.variations select').css({'color': 'red', 'border-color': 'red'}); | |
$('option').css('color','initial'); | |
return false; | |
} | |
}); | |
$('a.reset_variations').on("click change", function(e){ | |
$('.variations select').css({'color': 'red', 'border-color': 'red'}); | |
$('option').css('color','initial'); | |
}); | |
$('.variations select').on("click change", function(e){ | |
if ($('.variations select').val() !== "") { | |
$('.variations select').css({'color': 'green', 'border-color': 'green'}); | |
$('option').css('color','initial'); | |
} | |
}); | |
$('.variations select').on("click change", function(e){ | |
if ($('.variations select').val() === "") { | |
$('.variations select').css({'color': 'red', 'border-color': 'red'}); | |
$('option').css('color','initial'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment