skip to Main Content

Now, I have retrieved the element data. But, I don’t know how to get data of data-properties

enter image description here

I tried:
$('#checkout_shipping_address_id').on('select2:select', function (e) {
var data = e.params.data;
console.log(data.element.getAttribute[data-properties]);
});
but It's not working

2

Answers


    1. You have to change event handler to change instead of select
    2. If you need to get the attributes you can do it with attr method.
        $('#checkout_shipping_address_id').on('change', function (e) {
            var data = $(e.currentTarget).attr('data-properties')
            console.log(data); 
        });
    
    Login or Signup to reply.
  1. try this with selected handler.

    $('#checkout_shipping_address_id').on('change', function (e) {
            var data = $('#checkout_shipping_address_id option:selected').attr('data-properties')
            console.log(data); 
        });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search