this is a 2 part solution.
First you would need HTML markup that represent the alert (and the trigger button)
<button id="btnShowAlert" type="button">Click Me!</button>
<div id="myAlert" style="display: none;" class="alert alert-primary" role="alert">
my alternative message
</div>
Then secondly you would need the JavaScript (jQuery) that listens for click events on the button, then show the alert accordingly.
$('#btnShowAlert').on('click', function(){
$('#myAlert').style('display', 'block');
});
My question is… Are you perhaps looking for Modals ???
2
solved How to use bootstrap 4 alerts?