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
    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 that you have read and understand our privacy policy and code of conduct.

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