I'm new to jQuery. I have link with a data-id attribute which is dynamically updated from select option value
<a id="jabatanID" href="#" data-id="{{$jabatan_id}}" class="btn btn-warning btn-block assigndata">Click</a>
The idea is if data-id is empty, then fire swal.alert, and then if not empty show modal and pass the data-id value to input id
The click button event are work for the first attempt, the problem is when i change the option select value this event $(".modal-body #jabatan_id").val(jabatan_id); not update with the new data-id value, even though data-id="{{$jabatan_id}}" was updated with new value
$(document).ready(function () {
        $(".assigndata").click(function () {
            var jabatan_id = $(this).data('id');
            if(jabatan_id == ''){
                Swal.fire({title: "Warning", text: "Please Choose jabatan ID", icon:"warning"});
            }
            else {
                $('#attachsertifikat').modal('show');
                $(".modal-body #jabatan_id").val(jabatan_id);
            }
        });
    });
Is there any cache on data-id that i have to reset or something??
Update with jsfiddle
 
     
    