To put the record ID in the Modal window?

Good time of day.
I have a list of records that are displayed from the database.
Every record has
<a class="delobj" href="handlers/delete_object.php?id_obj=13220" data-obj="13220"><img src="/img/icon_delete_object.png"></a>
a link to a handler which deletes the entry from the database GET method.

There is a modal window
<div class="modal fade" id="default-example-modal-sm-center" tabindex="-1" role="dialog" style="display: none;" aria-hidden="true">
 <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
 <div class="modal-content">
 <div class="modal-header">
 <h5 class="modal-title">are you sure You want to delete record?</h5>
 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
 <span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>
</div>
 <div class="modal-body">
 the text of the message
</div>
 <div class="modal-footer">
 <button type="button" class="btn btn-secondary waves-effect waves-themed" data-dismiss="modal">Cancel</button>
 <button type="button" class="btn btn-primary waves-effect waves-themed">Delete record</button>
</div>
</div>
</div>
</div>

How to make by clicking on the recording link that leads to destruction, there is a modal window, confirm the deletion by clicking "Delete record" is removed is the entry that is equal to id_obj.

Thanks in advance for your help.
April 19th 20 at 12:04
1 answer
April 19th 20 at 12:06
<a class="delobj" href="javascript:void(0)" data-obj="13220">
 <img src="/img/icon_delete_object.png">
</a>
function($){
 $('.delobj').on('click', function(){
 if(confirm('Sure?')) {
 window.location.href = 'handlers/delete_object.php?id_obj=' + $(this).attr('data-obj')
}
})
}(jQuery)


Code not derail nbrl right here. There may be errors or typos, it the idea should be clear.

Find more questions by tags jQueryPHP