1

I am trying to get the selected color swatch value in options.phtml

module-catalog/view/frontend/template/product/view/options.‌​phtml

file with following code.But i am not able to get the value.

enter image description here

<script>
   require([
    'jquery',
    'Magento_Catalog/js/price-box'
], function($){
    jQuery(document).ready(function(){
        //for swatches1
        $('.swatch-option').click(function () {
            alert('hello');
        });
    });

});

 </script>
1
  • can any one provide the solution
    – Ramesh
    Commented Jun 29, 2017 at 14:49

1 Answer 1

5

It's working fine When i tried like this.

  $('body').on('click', '.swatch-option', function(e) {
       alert("hello");
        var swatchid = $('.swatch-attribute').attr('option-selected');
        var swatchattributeid = $('.swatch-attribute').attr('attribute-id');

    });

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.