Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FrancoStino/1b2de9147a5b07dee4e7d1d48f2b743a to your computer and use it in GitHub Desktop.
Save FrancoStino/1b2de9147a5b07dee4e7d1d48f2b743a to your computer and use it in GitHub Desktop.
Change color of select variation after alert Jquery - Woocommerce
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