0

I have a small pickle. I can't figure out how to turn the css off after it gets activated. If the user changes their mind, I want the yellow to turn off if they deselect the button (variation). I can't figure this out.

    $( ".variations_form" ).on( "woocommerce_variation_select_change", function () {
    $(".ivpa_clicked").css("background-color", "yellow")
} );
 
$( ".single_variation_wrap" ).on( "show_variation", function ( event, variation ) {
    // Fired when the user selects all the required dropdowns / attributes
    // and a final variation is selected / shown
    $(".ivpa_clicked").css("background-color", "green")
} );

here's the page I'm working with: https://testusers.newisw.com/product/girls-blazer/

Side Note: I tried this too, but no luck turning it off:

jQuery(document).ready(function( $ ){
  $  ( "form.variations_form" ).on( "woocommerce_variation_select_change", function () {
 if ($(".ivpa_clicked").css("background-color", "yellow"));
    else if 
     ($ (".ivpa_clicked").css("background-color", "transparent !important"));
 }
   );
  });

what am I doing wrong?

1 Answer 1

0

UPDATE! Turns out, I could use or (hack into) the existing CSS from whatever plug-in I'm using, and change or modify the look of the CSS. This way the functionality stays the same, allowing me to simply “decorate” in CSS. Your plug-ins code may vary in technique from mine, but over all just find the existing code/class/script, whatever, and build off it.

So in the end, I did NOT use any of the code in my original posting. In my case, the plugin I have used simple CSS to turn ON and OFF the variations, so I just tweaked my own look around it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.