How to add variables from button to html output in jQuery

Solution:

To solve this using the following:

   window.onload = function () {    
            
            
             
            
            jQuery(document).ready() 
            
            jQuery(function(){
                
                
                
               
                
                
                
               jQuery( ".add-pe" ).click(function() {
                   
                   
                   var dataId = jQuery(this).attr("data-id")
                   var title = jQuery(this).attr("title")
                   
                   
                jQuery(".values-list").append('<li><input type="hidden" name="acf[field_61e58083d6d49][]" value="' + dataId + '"><span data-id="' + dataId + '" class="acf-rel-item">' + title + '<a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a></span></li>');
});
            });
        };

<p><a class="add-pe btn btn-secondary btn-sm mt-4" data-id="<?php echo $post_ID; ?>" title="<?php echo $title?>">Add to claim</a></p>